From 9141eaa70790a77c2952a67236a37651df2a620f Mon Sep 17 00:00:00 2001 From: yangjixian Date: Fri, 22 Apr 2011 13:35:22 +0000 Subject: [PATCH] git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1595 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/lazimageeditor/DLBitmap.pas | 3 +- applications/lazimageeditor/DLBmpUtils.inc | 48 ++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/applications/lazimageeditor/DLBitmap.pas b/applications/lazimageeditor/DLBitmap.pas index 766837938..f3df8f91c 100644 --- a/applications/lazimageeditor/DLBitmap.pas +++ b/applications/lazimageeditor/DLBitmap.pas @@ -88,6 +88,7 @@ procedure SprayPoints(DLBmp: TDLBitmap; X, Y: integer; Radians: integer; PColor: function GetRColor(const Color: TColor): Byte; function GetGColor(const Color: TColor): Byte; function GetBColor(const Color: TColor): Byte; +procedure SprayPoints(aCanvas: TCanvas; X, Y: integer; Radians: Integer; PColor: TColor); implementation @@ -377,7 +378,7 @@ end; procedure TDLBitmap.Spray(x, y, radian: integer; PColor: TColor); begin - SprayPoints(Self, x, y, radian, PColor); + SprayPoints(Self.Canvas, x, y, radian, PColor); end; procedure TDLBitmap.FillEllipse(X1, Y1, X2, Y2: integer); diff --git a/applications/lazimageeditor/DLBmpUtils.inc b/applications/lazimageeditor/DLBmpUtils.inc index c00339f49..85e8f7268 100644 --- a/applications/lazimageeditor/DLBmpUtils.inc +++ b/applications/lazimageeditor/DLBmpUtils.inc @@ -558,5 +558,53 @@ begin Result := (Color and $FF0000) shr 16; end; +procedure SprayPoints(aCanvas: TCanvas; X, Y: integer; Radians: Integer; PColor: TColor); +var + i, a, b, temp, ci, center: Integer; +begin + if aCanvas = nil then + Exit; + Randomize; + for i := 0 to Radians do + begin + temp := Random(100); + a := Random(Round(Radians * 0.65)); + if (temp < 50) then a := 0 - a; + temp := Random(100); + b := Random(Round(Radians * 0.65)); + if (temp < 50) then b := 0 - b; + if (a * a + b * b < Sqr(Round(Radians * 0.65))) then + begin + aCanvas.Pixels[X + a, Y + b] := PColor; + end; + end; + for i := 0 to Radians div 3 do + begin + temp := Random(100); + a := Random(Round(Radians * 0.65)); + if (temp < 50) then a := 0 - a; + temp := Random(100); + b := Random(Round(Radians * 0.65)); + if (temp < 50) then b := 0 - b; + if (a * a + b * b < Sqr(Round(Radians * 0.65))) then + begin + aCanvas.Pixels[X + a, Y + b] := PColor; + end; + end; + for i := 0 to Radians * 2 div 3 do + begin + temp := Random(100); + a := Random(Round(Radians * 0.65)); + if (temp < 50) then a := 0 - a; + temp := Random(100); + b := Random(Round(Radians * 0.65)); + if (temp < 50) then b := 0 - b; + if (a * a + b * b < Sqr(Round(Radians * 0.65))) then + begin + aCanvas.Pixels[X + a, Y + b] := PColor; + end; + end; +end; +