[Lazarus] TColor and Alpha channel support

Kostas Michalopoulos badsectoracula at gmail.com
Mon Sep 26 17:15:06 CEST 2016


Is there a need for alpha *everywhere* a color is used? From my experience,
i've only really needed alpha for TCanvas (so i can draw, e.g. translucent
rectangles). I don't think there is a need to add more baggage in controls
by introducing yet another mostly redundant FPColor property. Controls that
need color with alpha could just provide a ColorAlpha property (for Color
property - if a Color property is named Foreground or SecondaryColor then
the alpha would be ForegroundAlpha or SecondaryColorAlpha).

If one doesn't care about compatibility with Delphi, a Color: TFPColor
property could be used and Lazarus be made (if it doesn't already) to
handle TFPColor similarly to TColor but with a custom dialog that can edit
the alpha.

For TCanvas, a TFPColor behind the scenes that is mapped to both TFPColor
and TColor properties on access should be enough. Yes, it is redundant, but
since most Canvas use is done via code (instead of a visual property
editor), i'd say that being able to access RGBA as a single value instead
of a value pair is cleaner.


On Mon, Sep 26, 2016 at 4:52 PM, Martin Schreiber via Lazarus <
lazarus at lists.lazarus-ide.org> wrote:

> On Monday 26 September 2016 15:01:04 Graeme Geldenhuys via Lazarus wrote:
> > On 2016-09-26 13:52, Martin Schreiber via Lazarus wrote:
> > > Or:
> > > "
> > >  Alpha := ...; // property Alpha: TColor
> > > "
> > > for alpha per colour channel.
> >
> > In that case I would make it a record type with RedAlpha, GreenAlpha and
> > BlueAlpha: Byte. Why?, Because TColor's range is way to large, with most
> > of the acceptable values being meaningless.
> >
> Using TColor has the advantage that the same mechanism of RGB-lookup
> of "logical" colours as with normal TColor values can be used. TColor with
> the MSB = 0 is a special case where the lower bytes contain the RGB values.
> Simple and efficient.
> In MSEgui the MSB defines the kind of the logical color value, "functional"
> (cl_invalid,cl_default..), "mapped" (cl_dkshadow,cl_shadow...), "named RGB"
> (cl_black, cl_dkgray...) and "user".
>
> Martin
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus-ide.org
> http://lists.lazarus-ide.org/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160926/5e8007a3/attachment.html>


More information about the Lazarus mailing list