diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-25 09:29:31 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-25 09:29:31 +0000 |
commit | 1a5fd690766d2dd1805a9b9d0b76d5caa9ffe528 (patch) | |
tree | 83ad623610c5e4b90aef852a994e5d48643e7f15 /src | |
parent | 083bdeb224ff6a54a0b494f3a08b067d1d478981 (diff) | |
download | fpGUI-1a5fd690766d2dd1805a9b9d0b76d5caa9ffe528.tar.xz |
* Implemented two new canvas functions. DrawArc() and FillArc()
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/gdi/gfx_gdi.pas | 46 | ||||
-rw-r--r-- | src/corelib/gfxbase.pas | 14 | ||||
-rw-r--r-- | src/corelib/x11/gfx_x11.pas | 14 |
3 files changed, 73 insertions, 1 deletions
diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas index 6aa7f910..8912957c 100644 --- a/src/corelib/gdi/gfx_gdi.pas +++ b/src/corelib/gdi/gfx_gdi.pas @@ -107,6 +107,8 @@ type procedure DoEndDraw; override; function GetPixel(X, Y: integer): TfpgColor; override; procedure SetPixel(X, Y: integer; const AValue: TfpgColor); override; + procedure DoDrawArc(x, y, w, h: TfpgCoord; a1, a2: double); override; + procedure DoFillArc(x, y, w, h: TfpgCoord; a1, a2: double); override; public constructor Create; override; destructor Destroy; override; @@ -1063,6 +1065,48 @@ begin Windows.SetPixel(Fgc, X, Y, fpgColorToWin(AValue)); end; +procedure TfpgCanvasImpl.DoDrawArc(x, y, w, h: TfpgCoord; a1, a2: double); +var + xr: double; + yr: double; +begin + xr := w / 2; + yr := h / 2; + Arc(Fgc, x, y, x+w, y+h, + Trunc(0.5 + x + xr + cos(a1)*xr), + Trunc(0.5 + y + yr - sin(a1)*yr), + Trunc(0.5 + x + xr + cos(a1+a2)*xr), + Trunc(0.5 + y + yr - sin(a1+a2)*yr) + ); +(* +var + SX, SY, EX, EY : Longint; +begin + {$Warning DoDrawArc needs testing. } + Angles2Coords(ARect.Left, ARect.Top, ARect.Right - ARect.Left, + ARect.Bottom - ARect.Top, StartAngle, EndAngle, SX, SY, EX, EY); + {$ifndef wince} + Windows.Arc(Handle, ARect.Left, ARect.Top, ARect.Right, + ARect.Bottom, SX, SY, EX, EY) + {$endif} +*) +end; + +procedure TfpgCanvasImpl.DoFillArc(x, y, w, h: TfpgCoord; a1, a2: double); +var + xr: double; + yr: double; +begin + xr := w / 2; + yr := h / 2; + Pie(Fgc, x, y, x+w, y+h, + Trunc(0.5 + x + xr + cos(a1)*xr), + Trunc(0.5 + y + yr - sin(a1)*yr), + Trunc(0.5 + x + xr + cos(a1+a2)*xr), + Trunc(0.5 + y + yr - sin(a1+a2)*yr) + ); +end; + procedure TfpgCanvasImpl.DoPutBufferToScreen(x, y, w, h: TfpgCoord); begin if FBufferBitmap > 0 then @@ -1250,7 +1294,7 @@ begin SelectObject(tmpdc, TfpgImageImpl(img).BMPHandle); if TfpgImageImpl(img).FIsTwoColor then - rop := PATCOPY //ROP_DSPDxax + rop := PATCOPY else rop := SRCCOPY; diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index 2b677e57..d66d1604 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -249,6 +249,8 @@ type procedure DoEndDraw; virtual; abstract; function GetPixel(X, Y: integer): TfpgColor; virtual; abstract; procedure SetPixel(X, Y: integer; const AValue: TfpgColor); virtual; abstract; + procedure DoDrawArc(x, y, w, h: TfpgCoord; a1, a2: double); virtual; abstract; + procedure DoFillArc(x, y, w, h: TfpgCoord; a1, a2: double); virtual; abstract; public constructor Create; virtual; destructor Destroy; override; @@ -257,12 +259,14 @@ type procedure DrawLine(x1, y1, x2, y2: TfpgCoord); procedure DrawImage(x, y: TfpgCoord; img: TfpgImageBase); procedure DrawImagePart(x, y: TfpgCoord; img: TfpgImageBase; xi, yi, w, h: integer); + procedure DrawArc(x, y, w, h: TfpgCoord; a1, a2: double); procedure StretchDraw (x, y, w, h: TfpgCoord; ASource: TfpgImageBase); procedure CopyRect(x, y: TfpgCoord; ACanvas: TfpgCanvasBase; var SourceRect: TRect); procedure DrawString(x, y: TfpgCoord; const txt: string); procedure FillRectangle(x, y, w, h: TfpgCoord); overload; procedure FillRectangle(r: TfpgRect); overload; procedure FillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord); + procedure FillArc(x, y, w, h: TfpgCoord; a1, a2: double); procedure XORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord); overload; procedure XORFillRectangle(col: TfpgColor; r: TfpgRect); overload; procedure SetClipRect(const rect: TfpgRect); @@ -748,6 +752,11 @@ begin DoDrawImagePart(x, y, img, xi, yi, w, h); end; +procedure TfpgCanvasBase.DrawArc(x, y, w, h: TfpgCoord; a1, a2: double); +begin + DoDrawArc(x, y, w, h, a1, a2); +end; + procedure TfpgCanvasBase.StretchDraw(x, y, w, h: TfpgCoord; ASource: TfpgImageBase); var i: TfpgCustomInterpolation; @@ -822,6 +831,11 @@ begin DoFillTriangle(x1, y1, x2, y2, x3, y3); end; +procedure TfpgCanvasBase.FillArc(x, y, w, h: TfpgCoord; a1, a2: double); +begin + DoFillArc(x, y, w, h, a1, a2); +end; + procedure TfpgCanvasBase.XORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord); begin DoXORFillRectangle(col, x, y, w, h); diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas index d5a09843..279c5eba 100644 --- a/src/corelib/x11/gfx_x11.pas +++ b/src/corelib/x11/gfx_x11.pas @@ -116,6 +116,8 @@ type procedure DoEndDraw; override; function GetPixel(X, Y: integer): TfpgColor; override; procedure SetPixel(X, Y: integer; const AValue: TfpgColor); override; + procedure DoDrawArc(x, y, w, h: TfpgCoord; a1, a2: double); override; + procedure DoFillArc(x, y, w, h: TfpgCoord; a1, a2: double); override; public constructor Create; override; destructor Destroy; override; @@ -1309,6 +1311,18 @@ begin {$Note We must still implement DrawPoint} end; +procedure TfpgCanvasImpl.DoDrawArc(x, y, w, h: TfpgCoord; a1, a2: double); +begin + XDrawArc(xapplication.display, FDrawHandle, Fgc, x, y, w-1, h-1, + Trunc(64 * a1), Trunc(64 * a2)); +end; + +procedure TfpgCanvasImpl.DoFillArc(x, y, w, h: TfpgCoord; a1, a2: double); +begin + XFillArc(xapplication.display, FDrawHandle, Fgc, x, y, w, h, + Trunc(64 * a1), Trunc(64 * a2)); +end; + procedure TfpgCanvasImpl.DoSetFontRes(fntres: TfpgFontResourceBase); begin if fntres = nil then |