[Lazarus] Do we really need a PaintSwastika procedure?

Dmitry Boyarintsev skalogryz.lists at gmail.com
Wed Jan 6 17:42:48 CET 2016


On Wed, Jan 6, 2016 at 11:20 AM, Vojtěch Čihák <vojtech.cihak at atlas.cz>
wrote:

> I vote for keeping procedure but there should be added boolean parameter +
> patch for painting anti-clockwise swastika (which is religious symbol
> only).
>

Fair enough.
Here's the patch. (Anyone,) please create a bug report, so it could be
applied.

thanks,
Dmitry


Index: extgraphics.pas
===================================================================
--- extgraphics.pas    (revision 51191)
+++ extgraphics.pas    (working copy)
@@ -56,7 +56,7 @@
 procedure PaintRightTriangle(Canvas: TCanvas; const PaintRect: TRect;
   RadAngle :Extended=0.0);
 procedure PaintSwastika(Canvas: TCanvas; const PaintRect: TRect;
-  RadAngle :Extended=0.0);
+  RadAngle :Extended=0.0; ClockWise: Boolean = true);
 procedure PaintTriangle(Canvas: TCanvas; const PaintRect: TRect;
   RadAngle :Extended=0.0);
 procedure PaintTriangular(Canvas: TCanvas; const PaintRect: TRect;
@@ -583,8 +583,10 @@
 end;


-procedure InitSwastika(var P:array of TPoint;const R: TRect;var
NumPts:Integer);
+procedure InitSwastika(var P:array of TPoint;const R: TRect;var
NumPts:Integer; CW: Boolean = true);
 var x1,x2,y1,y2:Integer;
+  t: TPoint;
+  i: integer;
 begin
   x1:=(R.Right-R.Left) div 5;
   y1:=(R.Bottom-R.Top) div 5;
@@ -601,8 +603,21 @@

P[16].x:=P[15].x;P[16].y:=R.Bottom-y1;P[17].x:=R.Left+x2;P[17].y:=P[16].y;
   P[18].x:=P[17].x;P[18].y:=R.Bottom-y2;P[19].x:=R.Left;P[19].y:=P[18].y;
   NumPts:=20;
+  if not CW then
+    for i:=0 to NumPts -1 do
+      p[i].x:=R.Right - (p[i].x - R.left);
 end;

+procedure InitSwastikaCW(var P:array of TPoint;const R: TRect;var
NumPts:Integer);
+begin
+  InitSwastika(P, R, NumPts, true);
+end;
+
+procedure InitSwastikaCCW(var P:array of TPoint;const R: TRect;var
NumPts:Integer);
+begin
+  InitSwastika(P, R, NumPts, false);
+end;
+
 procedure InitTriangle(var P:array of TPoint; const R: TRect;
   var NumPts:Integer);
 begin
@@ -719,9 +734,12 @@
   InitPolygon(Canvas,PaintRect,RadAngle, at InitRightTriangle);
 end;

-procedure PaintSwastika(Canvas: TCanvas; const PaintRect: TRect;RadAngle
:Extended=0.0);
+procedure PaintSwastika(Canvas: TCanvas; const PaintRect: TRect;RadAngle
:Extended=0.0; ClockWise: Boolean = true);
 begin
-  InitPolygon(Canvas,PaintRect,RadAngle, at InitSwastika);
+  if ClockWise then
+    InitPolygon(Canvas,PaintRect,RadAngle, at InitSwastikaCW)
+  else
+    InitPolygon(Canvas,PaintRect,RadAngle, at InitSwastikaCCW);
 end;

 procedure PaintTriangle(Canvas: TCanvas; const PaintRect: TRect;RadAngle
:Extended=0.0);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160106/9a0665de/attachment-0003.html>
-------------- next part --------------
Index: extgraphics.pas
===================================================================
--- extgraphics.pas	(revision 51191)
+++ extgraphics.pas	(working copy)
@@ -56,7 +56,7 @@
 procedure PaintRightTriangle(Canvas: TCanvas; const PaintRect: TRect;
   RadAngle :Extended=0.0);
 procedure PaintSwastika(Canvas: TCanvas; const PaintRect: TRect;
-  RadAngle :Extended=0.0);
+  RadAngle :Extended=0.0; ClockWise: Boolean = true);
 procedure PaintTriangle(Canvas: TCanvas; const PaintRect: TRect;
   RadAngle :Extended=0.0);
 procedure PaintTriangular(Canvas: TCanvas; const PaintRect: TRect;
@@ -583,8 +583,10 @@
 end;
 
 
-procedure InitSwastika(var P:array of TPoint;const R: TRect;var NumPts:Integer);
+procedure InitSwastika(var P:array of TPoint;const R: TRect;var NumPts:Integer; CW: Boolean = true);
 var x1,x2,y1,y2:Integer;
+  t: TPoint;
+  i: integer;
 begin
   x1:=(R.Right-R.Left) div 5;
   y1:=(R.Bottom-R.Top) div 5;
@@ -601,8 +603,21 @@
   P[16].x:=P[15].x;P[16].y:=R.Bottom-y1;P[17].x:=R.Left+x2;P[17].y:=P[16].y;
   P[18].x:=P[17].x;P[18].y:=R.Bottom-y2;P[19].x:=R.Left;P[19].y:=P[18].y;
   NumPts:=20;
+  if not CW then
+    for i:=0 to NumPts -1 do
+      p[i].x:=R.Right - (p[i].x - R.left);
 end;
 
+procedure InitSwastikaCW(var P:array of TPoint;const R: TRect;var NumPts:Integer);
+begin
+  InitSwastika(P, R, NumPts, true);
+end;
+
+procedure InitSwastikaCCW(var P:array of TPoint;const R: TRect;var NumPts:Integer);
+begin
+  InitSwastika(P, R, NumPts, false);
+end;
+
 procedure InitTriangle(var P:array of TPoint; const R: TRect;
   var NumPts:Integer);
 begin
@@ -719,9 +734,12 @@
   InitPolygon(Canvas,PaintRect,RadAngle, at InitRightTriangle);
 end;
 
-procedure PaintSwastika(Canvas: TCanvas; const PaintRect: TRect;RadAngle :Extended=0.0);
+procedure PaintSwastika(Canvas: TCanvas; const PaintRect: TRect;RadAngle :Extended=0.0; ClockWise: Boolean = true);
 begin
-  InitPolygon(Canvas,PaintRect,RadAngle, at InitSwastika);
+  if ClockWise then
+    InitPolygon(Canvas,PaintRect,RadAngle, at InitSwastikaCW)
+  else
+    InitPolygon(Canvas,PaintRect,RadAngle, at InitSwastikaCCW);
 end;
 
 procedure PaintTriangle(Canvas: TCanvas; const PaintRect: TRect;RadAngle :Extended=0.0);


More information about the Lazarus mailing list