X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fflexui%2Ffui_common.pas;h=38afcbb424d0a7d592f8e6aa963d4d05017e81b0;hb=HEAD;hp=744ddff1bd71de3c59974e8e70b34aac3e263c92;hpb=6880f8a491a247a34d6afb5508d0a64196a3d26d;p=d2df-sdl.git diff --git a/src/flexui/fui_common.pas b/src/flexui/fui_common.pas index 744ddff..38afcbb 100644 --- a/src/flexui/fui_common.pas +++ b/src/flexui/fui_common.pas @@ -3,8 +3,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -86,6 +85,8 @@ type function isOpaque (): Boolean; inline; function isTransparent (): Boolean; inline; + function toString (): AnsiString; + // WARNING! This function does blending in RGB space, and RGB space is not linear! // alpha value of `self` doesn't matter // `aa` means: 255 for replace color, 0 for keep `self` @@ -102,6 +103,8 @@ type function empty (): Boolean; inline; // invalid rects are empty too function valid (): Boolean; inline; + function toString (): AnsiString; + // modifies this rect, so it won't be bigger than `r` // returns `false` if this rect becomes empty function intersect (constref r: TGxRect): Boolean; inline; @@ -195,6 +198,12 @@ begin result.a := a; end; +function TGxRGBA.toString (): AnsiString; +begin + if (a = 255) then result := formatstrf('rgb(%s,%s,%s)', [r, g, b]) + else result := formatstrf('rgba(%s,%s,%s,%s)', [r, g, b, a]); +end; + // ////////////////////////////////////////////////////////////////////////// // constructor TGxRect.Create (ax, ay, aw, ah: Integer); begin x := ax; y := ay; w := aw; h := ah; end; @@ -207,6 +216,8 @@ begin result := intersectRect(x, y, w, h, r.x, r.y, r.w, r.h); end; +function TGxRect.toString (): AnsiString; begin result := formatstrf('(%s,%s;%sx%s)', [x, y, w, h]); end; + // ////////////////////////////////////////////////////////////////////////// // constructor TGxOfs.Create (axofs, ayofs: Integer); begin xofs := axofs; yofs := ayofs; end;