From 91483bb56d8aa1f5969ceaa00650d6a11d68778e Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Thu, 16 Jun 2011 10:56:47 +0000 Subject: [PATCH] fpvectorial: minor fixes and commenting git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1685 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../fpvviewer/fpvectorialsrc/fpvutils.pas | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/applications/fpvviewer/fpvectorialsrc/fpvutils.pas b/applications/fpvviewer/fpvectorialsrc/fpvutils.pas index 18a121745..e8662d93f 100644 --- a/applications/fpvviewer/fpvectorialsrc/fpvutils.pas +++ b/applications/fpvviewer/fpvectorialsrc/fpvutils.pas @@ -27,10 +27,15 @@ type // Color Conversion routines function FPColorToRGBHexString(AColor: TFPColor): string; function RGBToFPColor(AR, AG, AB: byte): TFPColor; inline; +// Other routine +function CanvasCoordsToFPVectorial(AY: Integer; AHeight: Integer): Integer; inline; function SeparateString(AString: string; ASeparator: char): T10Strings; implementation +{@@ This function is utilized by the SVG writer and some other places, so + it shouldn't be changed. +} function FPColorToRGBHexString(AColor: TFPColor): string; begin Result := Format('%.2x%.2x%.2x', [AColor.Red shr 8, AColor.Green shr 8, AColor.Blue shr 8]); @@ -38,18 +43,23 @@ end; function RGBToFPColor(AR, AG, AB: byte): TFPColor; inline; begin - if AR > $100 then Result.Red := (AR shl 8) + $FF - else Result.Red := AR shl 8; - - if AR > $100 then Result.Green := (AG shl 8) + $FF - else Result.Green := AG shl 8; - - if AR > $100 then Result.Blue := (AB shl 8) + $FF - else Result.Blue := AB shl 8; - + Result.Red := (AR shl 8) + AR; + Result.Green := (AG shl 8) + AG; + Result.Blue := (AB shl 8) + AB; Result.Alpha := $FFFF; end; +{@@ 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; + {@@ Reads a string and separates it in substring using ASeparator to delimite them.