Hi I'm learing how to use canvas and I like it.
But my knowledge about geometry is really bad, I need to read it again.
I try to draw rectangles and work so so, that's because I can draw the rectable if I paint from the left to the right, but I paint the right to the left not show the rectangle. I show my bad code.
B4X:
Rectangulo.Top=posY_at_click
Rectangulo.Left=posX_at_click
Rectangulo.Bottom = y
Rectangulo.Right= X
canvas_temp.DrawRect(Rectangulo, xui.Color_Black, False, 2)
I try to draw an arrow with B4xpath and .Lineto and I cant at the moment, then I try with draw a bitmap with an arrow inside and goes crazy in some rotations.
B4X:
Rectangulo.Top=posY_at_click
Rectangulo.Left=posX_at_click
Rectangulo.Bottom = y
Rectangulo.Right= X
angulo = ATan2D(Y-posY_at_click, x-posX_at_click)
canvas_temp.DrawLine(posX_at_click, posY_at_click, X, Y, xui.Color_Black, 2)
canvas_temp.DrawBitmapRotated(fx.LoadImageSample(File.DirAssets, "flecha1.png", 80dip, 80dip),Rectangulo, angulo)
If posY_inicio < y Then
Rectangulo.Top=posY_inicio
Rectangulo.Left=posX_inicio
Rectangulo.Bottom=y
Rectangulo.Right=x
else if posY_inicio > y Then
Rectangulo.Top=y
Rectangulo.Left=posX_inicio
Rectangulo.Bottom=posY_inicio
Rectangulo.Right=x
else if posX_inicio < x Then
' Rectangulo.Top = posY_inicio
' Rectangulo.Left = x
' Rectangulo.Bottom = y
' Rectangulo.Right = posX_inicio
Else if posX_inicio > x Then
Rectangulo.Top = y
Rectangulo.Left = x
Rectangulo.Bottom = posY_inicio
Rectangulo.Right = posX_inicio
End If
canvas_temp.DrawRect(Rectangulo, xui.Color_Black, False, 2)
Now work from down to top, but not left to right, on the best case show a line from the left to the right.