I was trying to understand employing "Path" to draw part of a circle (post #6 in:
http://www.b4x.com/forum/basic4android-updates-questions/8547-trigonometric-circle.html.
I "slightly" modified the code to additionally plot the points of the path using the "DrawPoint" function. The points are plotted far outside of the circle.
My question is, are the coordinate systems different in "Draw..." and "Path"? Or what is the reason for that behaviour?
Thanks for an answer, positrom2
http://www.b4x.com/forum/basic4android-updates-questions/8547-trigonometric-circle.html.
I "slightly" modified the code to additionally plot the points of the path using the "DrawPoint" function. The points are plotted far outside of the circle.
My question is, are the coordinate systems different in "Draw..." and "Path"? Or what is the reason for that behaviour?
B4X:
Sub Process_Globals
End Sub
Sub Globals
Dim canvas1 As Canvas
End Sub
Sub Activity_Create(FirstTime As Boolean)
canvas1.Initialize(Activity)
DrawArc(canvas1, 100dip, 100dip, 100dip, 180, 90, Colors.Blue)
Activity.Invalidate
End Sub
Sub DrawArc(cnvs As Canvas, x As Float, y As Float, radius As Float, startAngle As Float, endAngle As Float, Color As Int)
Dim s As Float,x1,y1 As Int
s = startAngle
startAngle = 180 - endAngle
endAngle = 180 - s
If startAngle >= endAngle Then endAngle = endAngle + 360
Dim p As Path
p.Initialize(x, y)
For i = startAngle To endAngle Step 10
x1=x+2 * radius * SinD(i)
y1=y+2 * radius * CosD(i)
cnvs.DrawPoint(x1,y1,Colors.yellow)
Log(i&" "&x1&" "&y1)
p.LineTo(x1 , y1)
Next
p.LineTo(x + 2 * radius * SinD(endAngle), y + 2 * radius * CosD(endAngle))
p.LineTo(x, y)
cnvs.ClipPath(p) 'We are limiting the drawings to the required slice
cnvs.DrawCircle(x, y, .5*radius, Colors.red, False, 0)
cnvs.RemoveClip
End Sub
Thanks for an answer, positrom2