[Lazarus] FPVectorial and TAChart

Alexander Klenin klenin at gmail.com
Thu Jun 16 14:44:22 CEST 2011


(Quoted in full, since original mail apparently did not made it to the list)

On Thu, Jun 16, 2011 at 21:46, Felipe Monteiro de Carvalho
<felipemonteiro.carvalho at gmail.com> wrote:
> One more thing: Your chart is upside down. It seams that you didn't
> think about the fact that the TCanvas and FPVectorial coordinates are
> different.
>
> TCanvas works like this, which is the usual for raster images:
>
> -----> X grows to the right
> |
> |
> y grows down, starting on the top
>
> FPVectorial uses the standard coordinates for vectorial documents instead:
>
> y grows upwards, starting on the bottom
> |
> |
> ----> X grows to the right
>
> I added a function that you can use in the unit fpvutils:
>
> {@@ Converts the coordinate system from a TCanvas to FPVectorial
>    The basic difference is that the Y axis is positioned differently and
>    points upwards in FPVectorial and downwards in TCanvas.
>    The X axis doesn't change. The fix is trivial and requires only
> the Height of
>    the Canvas as extra info.
> }
> function CanvasCoordsToFPVectorial(AY: Integer; AHeight: Integer):
> Integer; inline;
> begin
>  Result := AHeight - AY;
> end;

You are right, I did not know it. Maybe it should be mentioned in the wiki.
It is, however, not quite simple.
First, depending on interpretation, formula may be
(ABottom - AY) or even (ABottom + ATop - AY) -- I am not sure which is
preferable.

Also there is a question of text positioning -- do I understand correctly that
FPVectorial uses given coordinates as bottom-left point of text rectangle
instead of top-left?

-- 
Alexander S. Klenin




More information about the Lazarus mailing list