diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-10-26 13:56:09 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-10-26 13:56:09 +0000 |
commit | 16f3f057a567b3fc539ed55521e2996b26bcb2c4 (patch) | |
tree | c5906158cd50feee56f855cbbeeee76a9d8c634d | |
parent | c0a5ef4d7da723cb0f8831d907f397409d00912c (diff) | |
download | fpGUI-16f3f057a567b3fc539ed55521e2996b26bcb2c4.tar.xz |
* Updated the ThreeDee prototype with a new gradient function.
* Implemented a new fpgGetAvgColor function in gfxbase unit.
* Supplied some more documentation for gfxbase unit.
-rw-r--r-- | docs/html/corelib.cnt | 14 | ||||
-rw-r--r-- | docs/xml/corelib/gfxbase.xml | 44 | ||||
-rw-r--r-- | prototypes/fpgui2/tests/frm_threedee.pas | 57 | ||||
-rw-r--r-- | prototypes/fpgui2/tests/threedee.lpi | 3 | ||||
-rw-r--r-- | src/corelib/gfxbase.pas | 16 |
5 files changed, 123 insertions, 11 deletions
diff --git a/docs/html/corelib.cnt b/docs/html/corelib.cnt index 28cf9fbc..021f3742 100644 --- a/docs/html/corelib.cnt +++ b/docs/html/corelib.cnt @@ -592,6 +592,7 @@ SetHeight gfxbase/tfpgwindowbase.setheight.html SetWidth gfxbase/tfpgwindowbase.setwidth.html Create gfxbase/tfpgwindowbase.create.html + AfterConstruction gfxbase/tfpgwindowbase.afterconstruction.html AdjustWindowStyle gfxbase/tfpgwindowbase.adjustwindowstyle.html SetWindowParameters gfxbase/tfpgwindowbase.setwindowparameters.html Right gfxbase/tfpgwindowbase.right.html @@ -630,6 +631,7 @@ fpgGetGreen gfxbase/fpggetgreen.html fpgGetBlue gfxbase/fpggetblue.html fpgGetAlpha gfxbase/fpggetalpha.html + fpgGetAvgColor gfxbase/fpggetavgcolor.html PtInRect gfxbase/ptinrect.html SortRect gfxbase/sortrect.html gfx_x11 gfx_x11/index.html @@ -823,6 +825,8 @@ fpgfx fpgfx/index.html AllAnchors fpgfx/allanchors.html cMessageQueueSize fpgfx/cmessagequeuesize.html + fpGUIVersion fpgfx/fpguiversion.html + fpGUIName fpgfx/fpguiname.html TOrientation fpgfx/torientation.html TAlign fpgfx/talign.html TAnchor fpgfx/tanchor.html @@ -1015,13 +1019,14 @@ gfx_stdimages gfx_stdimages/index.html fpgCreateStandardImages gfx_stdimages/fpgcreatestandardimages.html gfx_UTF8utils gfx_utf8utils/index.html - UTF8Pos gfx_utf8utils/utf8pos.html + UTF8CharacterLength gfx_utf8utils/utf8characterlength.html + UTF8CharStart gfx_utf8utils/utf8charstart.html UTF8Copy gfx_utf8utils/utf8copy.html + UTF8CStringToUTF8String gfx_utf8utils/utf8cstringtoutf8string.html UTF8Length gfx_utf8utils/utf8length.html - UTF8CharStart gfx_utf8utils/utf8charstart.html - UTF8CharacterLength gfx_utf8utils/utf8characterlength.html - UTF8Insert gfx_utf8utils/utf8insert.html + UTF8Pos gfx_utf8utils/utf8pos.html UTF8Delete gfx_utf8utils/utf8delete.html + UTF8Insert gfx_utf8utils/utf8insert.html gfx_widget gfx_widget/index.html TFocusSearchDirection gfx_widget/tfocussearchdirection.html TfpgWidget gfx_widget/tfpgwidget.html @@ -1291,6 +1296,7 @@ 2MSetHeight 2MSetWidth 3MCreate +3MAfterConstruction 3MAdjustWindowStyle 3MSetWindowParameters 3MRight diff --git a/docs/xml/corelib/gfxbase.xml b/docs/xml/corelib/gfxbase.xml index 190885fd..9d086890 100644 --- a/docs/xml/corelib/gfxbase.xml +++ b/docs/xml/corelib/gfxbase.xml @@ -7651,12 +7651,14 @@ titlebars or borders inside a main parent window. <!-- function Visibility: default --> <element name="fpgColorToRGBTriple"> -<short></short> +<short>Converts the TfpgColor to TRGBTriple type</short> <descr> +This function converts the given TfpgColor into a TRGBTriple type. </descr> <errors> </errors> <seealso> + <link id="TRGBTriple" /> </seealso> </element> @@ -7672,12 +7674,14 @@ titlebars or borders inside a main parent window. <!-- function Visibility: default --> <element name="RGBTripleTofpgColor"> -<short></short> +<short>Converts the TRGBTriple to TfpgColor type</short> <descr> +This function converts the given TRGBTriple into a TfpgColor type. </descr> <errors> </errors> <seealso> + <link id="TRGBTriple" /> </seealso> </element> @@ -7693,7 +7697,7 @@ titlebars or borders inside a main parent window. <!-- function Visibility: default --> <element name="fpgGetRed"> -<short></short> +<short>Returns the Red portion of a color value.</short> <descr> </descr> <errors> @@ -7714,7 +7718,7 @@ titlebars or borders inside a main parent window. <!-- function Visibility: default --> <element name="fpgGetGreen"> -<short></short> +<short>Returns the Green portion of a color value.</short> <descr> </descr> <errors> @@ -7735,7 +7739,7 @@ titlebars or borders inside a main parent window. <!-- function Visibility: default --> <element name="fpgGetBlue"> -<short></short> +<short>Returns the Blue portion of a color value.</short> <descr> </descr> <errors> @@ -7756,7 +7760,7 @@ titlebars or borders inside a main parent window. <!-- function Visibility: default --> <element name="fpgGetAlpha"> -<short></short> +<short>Returns the Alpha portion of a color value.</short> <descr> </descr> <errors> @@ -7776,6 +7780,34 @@ titlebars or borders inside a main parent window. </element> <!-- function Visibility: default --> +<element name="fpgGetAvgColor"> +<short>Calculates the average color using the two supplied</short> +<descr> +This function calculates and returns the average color by using AColor1 +and AColor2. The Alpha value also gets taken into account. +</descr> +<errors> +</errors> +<seealso> +</seealso> +</element> + +<!-- function result Visibility: default --> +<element name="fpgGetAvgColor.Result"> +<short></short> +</element> + +<!-- argument Visibility: default --> +<element name="fpgGetAvgColor.AColor1"> +<short></short> +</element> + +<!-- argument Visibility: default --> +<element name="fpgGetAvgColor.AColor2"> +<short></short> +</element> + +<!-- function Visibility: default --> <element name="PtInRect"> <short></short> <descr> diff --git a/prototypes/fpgui2/tests/frm_threedee.pas b/prototypes/fpgui2/tests/frm_threedee.pas index e9b4735d..a31a829e 100644 --- a/prototypes/fpgui2/tests/frm_threedee.pas +++ b/prototypes/fpgui2/tests/frm_threedee.pas @@ -118,6 +118,57 @@ Const 190,190,190,190,190,190,190,176,176,176,176,176,176,176,176,176,176, 176,176); +{ This procedure creates a sunken 3d effect in a rectangle with a color gradient } +procedure FillRectGradient(Canvas: TfpgCanvas; X, Y, W, H: TfpgCoord; + Strip: Integer; Astart, Astop: TfpgColor); +var + RGBStart: TRGBTriple; + RGBStop: TRGBTriple; + RDiff, GDiff, BDiff: Integer; + count: Integer; + i: Integer; + newcolor: TRGBTriple; + Hx, Hy: TfpgCoord; // Coordinates for Horizontal Lines + Vx, Vy: TfpgCoord; // Coordinates for Vertical Lines + avgcolor: TfpgColor; +begin + RGBStart := fpgColorToRGBTriple(fpgColorToRGB(AStart)); + RGBStop := fpgColorToRGBTriple(fpgColorToRGB(AStop)); + + count := Strip; + Hx := X; + Hy := Y; + Vx := X; + Vy := Y; + + RDiff := RGBStop.Red - RGBStart.Red; + GDiff := RGBStop.Green - RGBStart.Green; + BDiff := RGBStop.Blue - RGBStart.Blue; + +// Changing; + Canvas.BeginDraw; + for i := 0 to count do + begin + newcolor.Red := RGBStart.Red + (i * RDiff) div count; + newcolor.Green := RGBStart.Green + (i * GDiff) div count; + newcolor.Blue := RGBStart.Blue + (i * BDiff) div count; + + Canvas.SetLineStyle(1, lsSolid); + Canvas.SetColor(RGBTripleTofpgColor(newcolor)); + Canvas.DrawLine(Hx, Hy, W+2, Hy); // Horizontal Line + Canvas.DrawLine(Vx, Vy, Vx, H+2); // Vertical Line + // next Horizontal Line: one pixel lower, one pixel shorter on the left + Hx := Hx + 1; + Hy := Hy + 1; + // Next Vertical Line: One pixel to the right, one pixel shorter on top + Vx := Vx + 1; + Vy := Vy + 1 + end; + + // Changed; + Canvas.EndDraw; +end; + {@VFD_NEWFORM_IMPL} @@ -219,6 +270,7 @@ begin FontDesc := '#Edit1'; Text := '$800000'; OnChange := @edtThreeDeeChanged; + BackgroundColor := $F5F5F5; end; cbName1 := TfpgCheckBox.Create(self); @@ -267,6 +319,7 @@ begin SetPosition(48, 144, 120, 22); FontDesc := '#Edit1'; Text := '$800000'; + BackgroundColor := $B0C4DE end; Custom2 := TthreedeeEdit.Create(self); @@ -276,6 +329,7 @@ begin SetPosition(48, 80, 120, 22); FontDesc := '#Edit1'; Text := '$800000'; + BackgroundColor := $B0C4DE; end; lblName1 := TfpgLabel.Create(self); @@ -308,6 +362,7 @@ procedure TthreedeeEdit.Draw3DControlShadow(ARect: TfpgRect); var r: TfpgRect; begin +(* Canvas.DrawImage(ARect.Left, ARect.Top, FimgLeftTop); // Canvas.StretchDraw(1, 8, 7, ARect.Height, FimgLeft); r.SetRect(ARect.Left, 8, 8, ARect.Height); @@ -315,6 +370,8 @@ begin // Canvas.StretchDraw(8, 1, Width+5, 7, FimgTop); r.SetRect(8, ARect.Top, Width+5, 8); Canvas.GradientFill(r, clM2Grey, BackgroundColor, gdVertical); +*) + FillRectGradient(Canvas, ARect.Left, ARect.Top, ARect.Width, ARect.Height, 7, TfpgColor($777777), BackgroundColor); end; procedure TthreedeeEdit.SetErrorColor(const AValue: TfpgColor); diff --git a/prototypes/fpgui2/tests/threedee.lpi b/prototypes/fpgui2/tests/threedee.lpi index 7bbed4b6..6a613a8c 100644 --- a/prototypes/fpgui2/tests/threedee.lpi +++ b/prototypes/fpgui2/tests/threedee.lpi @@ -6,6 +6,8 @@ <General> <Flags> <SaveOnlyProjectUnits Value="True"/> + <MainUnitHasCreateFormStatements Value="False"/> + <MainUnitHasTitleStatement Value="False"/> </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> @@ -17,7 +19,6 @@ </VersionInfo> <PublishOptions> <Version Value="2"/> - <IgnoreBinaries Value="False"/> <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> </PublishOptions> diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index 173b8017..41430d7a 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -400,6 +400,8 @@ function fpgGetRed(const AColor: TfpgColor): word; function fpgGetGreen(const AColor: TfpgColor): word; function fpgGetBlue(const AColor: TfpgColor): word; function fpgGetAlpha(const AColor: TfpgColor): word; +function fpgGetAvgColor(const AColor1, AColor2: TfpgColor): TfpgColor; + { Points } function PtInRect(const ARect: TfpgRect; const APoint: TPoint): Boolean; @@ -635,6 +637,20 @@ begin Result := Word((AColor shr 32) and $FF); end; +function fpgGetAvgColor(const AColor1, AColor2: TfpgColor): TfpgColor; +var + c1, c2: TRGBTriple; + avg: TRGBTriple; +begin + c1 := fpgColorToRGBTriple(AColor1); + c2 := fpgColorToRGBTriple(AColor2); + avg.Red := c1.Red + (c2.Red - c1.Red) div 2; + avg.Green := c1.Green + (c2.Green - c1.Green) div 2; + avg.Blue := c1.Blue + (c2.Blue - c1.Blue) div 2; + avg.Alpha := c1.Alpha + (c2.Alpha - c1.Alpha) div 2; + Result := RGBTripleTofpgColor(avg); +end; + function PtInRect(const ARect: TfpgRect; const APoint: TPoint): Boolean; begin Result := (APoint.x >= ARect.Left) and |