if have some type of 2d object / figure shape. That should be drawn on canvs. The origin of that shape should be the center (originX = width/2, OriginY = width/2). But I see no way to get this width. Or is there something i missed in the docs?
I thought about this. But I use something like addCubic to add a cuveshape. I never really understood how these Controlpoints work. I managed to get a result, ok. But to calculate the width by code⊠Never ever⊠Is there some documentation about these controlpoints i have never found? Is there some code thats shows me the calculation of what controlpoints do?
The only other way I see is to draw the shape to a picture und go through its rgbsurface pixel by pixelâŠ
Not a nice way.
I think it would be easy for Xojo to give the width and height info for this object. One point more on this really long list of things that - I think - is necessary and not available.
Or From the other side: How do others solve that? I canât be the first one. In short, I have a canvas, there is a backgroundlayer. You can put Shapes on this layer. If you zoom in or out, you could not handle that with an origin of 0,0. It is mandatory to have the origin centered, otherwise the shape is âwalkingâ on the map. And espaceially for this case (zooming in and out) vector is the way to do it, not pixel. Perhaps I miss something, but then I didnât see it.
for this problem you only need to approximate the Bezier curves with a polygon.
For a FigureShape, you can then build a polygon by concatenating the curve sets.
from that, it is now easy to create:
figure.contains( X,Y ) as boolean
width and height of the figure
What you need is to implement curve flattening, using the Casteljau algorithm it is easy.
a fantastic source of information on Bezier curves: