Italian [B4J] Come disegnare un arco / settore circolare ?

amorosik

Expert
Licensed User
Per un Canvas, vedo che c'e' il DrawCircle ma non il DrawArc
La domanda e': come disegnare un arco o un settore circolare (tipo fetta di torta) ?
 

Star-Dust

Expert
Licensed User
Longtime User
Si
 

Star-Dust

Expert
Licensed User
Longtime User
Se usi B4XCanvas puoi ottenerlo con B4XPath.InitializeArc

Se vuoi usare Canvas di B4A
Arc:
Sub Activity_Create(FirstTime As Boolean)
   Dim c As Canvas
   c.Initialize(Activity)
   Dim p As Path
   p.Initialize(100dip, 100dip)
   Dim r As Rect
   r.Initialize(0dip, 0dip, 200dip, 200dip)
   AddArc(p, r, 0, 90)
   p.LineTo(100dip, 100dip)
   c.ClipPath(p)
   c.DrawColor(Colors.Red)
End Sub

Sub AddArc(p As Path, r As Rect, StartAngle As Float, SweepAngle As Float)
   Dim rf As JavaObject
   rf.InitializeNewInstance("android.graphics.RectF", Array (r))
   Dim jo As JavaObject = p
   jo.RunMethod("addArc", Array(rf, StartAngle, SweepAngle))
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…