[Gambas-user] Clipper counter-intuitivities
Benoît Minisini
gambas at ...1...
Fri Jun 19 01:56:45 CEST 2015
Le 18/06/2015 20:38, Tobias Boege a écrit :
> Hi Benoit,
>
> the attached project shows two strange behaviours of Polygon from the
> gb.clipper component.
>
> (1) Polygon._get() returns a new PointF object created on the fly from
> internal data. However, people would think that
>
> hPolygon[0].X = 20
>
> should modify the zeroth point's x coordinate to 20, which it doesn't
> in the current implementation. Can't we cache the PointF objects such
> that changes to the return values of _get() are updated into the
> Polygon?
>
To do that, we have to replace the PointF by a specific class
(PolygonPointF?) that is like PointF, but owns a reference on the
Polygon, so that updating the point updates the polygon.
There is the same trick with the Control.Font class, so that it behaves
the way you describe.
But it's heavy: it uses one pointer more for the two floating point
coordinates. So I don't really like it.
> (2) If I AddPoint() like this
>
> pPoint = New PointF(10, 10)
> hPolygon.AddPoint(pPoint)
> Print hPolygon[hPolygon.Max].X
>
> it yields zero, but I feel it should be 10. I have no explanation for
> this one.
The signature of the method was false. I fixed it in revision #7140.
Regards,
--
Benoît Minisini
More information about the User
mailing list