Recent

Author Topic: Tcolor and TBGRAPixel - now compatible??  (Read 310 times)

winni

  • Hero Member
  • *****
  • Posts: 602
Tcolor and TBGRAPixel - now compatible??
« on: October 03, 2019, 06:33:35 pm »
Hi!

A mistake leads me to this question. I have a procedure

Code: Pascal  [Select]
  1. DrawColors ( BgCol, Keycol,Txtcol : TColor);

But I called it by mistake wrong (??)

Code: Pascal  [Select]
  1. DrawColors (CSSHotPink,cssWhite,cssBlue);

No Compiler errros  happen. And the colors are shown correct.

I saw it once on the roadmap the TBGRAPixel should be made compatible to TColor. Did it happen inbetween and I did not realize?

Please  tell me if ther above is now legal code.

Winni


lainz

  • Hero Member
  • *****
  • Posts: 3313
    • Lainz
Re: Tcolor and TBGRAPixel - now compatible??
« Reply #1 on: October 03, 2019, 09:14:01 pm »
Yes, is legal code thanks to operator overloading, there is a conversion from bgra to tcolor in this case, but is handled automatically.

winni

  • Hero Member
  • *****
  • Posts: 602
Re: Tcolor and TBGRAPixel - now compatible??
« Reply #2 on: October 04, 2019, 02:59:29 pm »
Cool!

Thanx

circular

  • Hero Member
  • *****
  • Posts: 3053
    • Personal webpage
Re: Tcolor and TBGRAPixel - now compatible??
« Reply #3 on: October 06, 2019, 05:35:11 pm »
Indeed. And you can also use other colorspaces. For example:
Code: Delphi  [Select]
  1. DrawColors (TStdHSLA.New(330, 1, 0.71), cssWhite, TStdHSLA.New(240, 1, 0.5));

To see the list of colorspaces, write for example in your code "TBGRAPixel.From" or "CSSBlue.To" and show suggestions by pressing Ctrl-Space.
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 602
Re: Tcolor and TBGRAPixel - now compatible??
« Reply #4 on: October 06, 2019, 05:58:24 pm »
@circular

Great! All the color convertig routines are now needless. Shrinks my personal lib .
And it cuts down the amount of typing in future.

thanx a lot.

Winni