The GR32_VectorUtils.Circle method works different from my expectation

197 Views Asked by At

I'm using the following code blocks to draw a circle on TBitmap32 (x:0,y:0) points.

Pts := Circle(0,0,35);

PolylineFS(Bitmap32, Pts, clBlack32, True, 3);

However, the drawn circle is drawn behind the specified coordinates. Half of the circle is in the minus coordinates of the TBitmap32.

Pts := Circle(35,35,35);

When I try this line of code, the x coordinate is drawn almost to the correct point, but Y point is still not in the correct coordinate.

I want this function to act like TCanvas.Ellipse. I tried a lot of things, but I wasn't successful.

1

There are 1 best solutions below

1
David Heffernan On

The code performs as designed. The coordinates that you supply are the centre of the circle and the radius.

Naturally if you supply 0 as the centre, then half of the circle will have negative coordinates. Solve your problem by passing the coordinates of the centre of the circle.


I want this function to act like TCanvas.Ellipse.

That's not how programming against a third party interface works. The author of the third party library decides on the interface, and you have to follow it. In this case, the author of the library has decreed that you must supply the centre of the circle. You have no choice in this matter. You must follow the interface that has been defined by the library's author.

If you wish to supply coordinates in a different way you need to write an adaptor. You can write your own code that accepts coordinates in the form that you wish to use, and then have that code convert your coordinates into those required for the library.