Draw an Ellipse

alfcen

Well-Known Member
Licensed User
Longtime User
Perhaps I am getting senile, couldn't find anything like Canvas1.DrawEllipse().
Surely, under penalty of speed, it is possible to draw an ellipse or an arc by means of plotting points...
 

alfcen

Well-Known Member
Licensed User
Longtime User
Thank you, Andrew, also for confirming that I'm not (yet) senile :sign0095:
 
Upvote 0

derez

Expert
Licensed User
Longtime User
Until then... I use this workarround:

load an empty bitmap (transparent) to a square imageview, draw a circle on this imageview and then copy the bitmap using drawbitmap from the square source to the rectangular destination. The circle is stretched to an ellipse.

B4X:
Dim cn As Canvas
   Dim bmp As Bitmap
   Dim src, dst As Rect
   bmp.Initialize(File.DirAssets,"empty.png")
   emptyview.SetBackgroundImage(bmp)
   cn.Initialize(emptyview)
   cn.DrawCircle(emptyview.Width/2,emptyview.Height/2,emptyview.Width/2,selectedcolor,True,1)
   src.Initialize(0,0,emptyview.Width,emptyview.Height)
   dst.Initialize(circlepnl.Left,circlepnl.Top,circlepnl.Left+circlepnl.Width,circlepnl.Top + circlepnl.Height)
   
   cnvs.DrawBitmap(emptyview.Bitmap,src,dst)
   board.Invalidate2(dst)
 
Upvote 0

alfcen

Well-Known Member
Licensed User
Longtime User
Not bad. The idea was about an inclined ellipse such as an eccentric planet orbit
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…