Recent

Author Topic: [SOLVED] Problem setting UI component color to 'Orange'  (Read 4468 times)

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
[SOLVED] Problem setting UI component color to 'Orange'
« on: March 21, 2018, 03:58:30 pm »
I'm trying to set a label (or anything else) to an orange color, but it is coming out blue...

I'm using:

Code: Pascal  [Select][+][-]
  1. myTlabel.Font.Color:=$FFA500;

Using any of the pre-defined colors works, but I get the same problem when I define new constant as:

Code: Pascal  [Select][+][-]
  1. const
  2.   clOrange: TColor = $FFA500;

and then try to us clOrange as my font color.

Every time it comes out blue...

I'm confused.

-FM
« Last Edit: May 02, 2018, 02:13:27 pm by fatmonk »

WooBean

  • Full Member
  • ***
  • Posts: 229
Re: Problem setting UI component color to 'Orange'
« Reply #1 on: March 21, 2018, 04:18:41 pm »
Hi,

would you show the source stating that orange color (as TColor) is equal to $FFA500?
Do not belive that source. Millions applications paint coloured components but not yours one?

WooBean
« Last Edit: March 21, 2018, 04:23:30 pm by WooBean »
Platforms: Win7/64, Linux Mint Ulyssa/64

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Re: Problem setting UI component color to 'Orange'
« Reply #2 on: March 21, 2018, 04:44:48 pm »
I have shown the source code!

I am FFA500 is the RGB code for orange.

If I try to set a component to that colour explicitly it comes out blue.

If I define a new TColor constant to that value and use that it also comes out blue.

I don't know what you are asking for as I have shown the source code where I am defining a constant to use and the source code assigning the colour directly.

-FM

Bart

  • Hero Member
  • *****
  • Posts: 5265
    • Bart en Mariska's Webstek
Re: Problem setting UI component color to 'Orange'
« Reply #3 on: March 21, 2018, 04:54:40 pm »
Try $00A5FF instead. RGB does not translate to "$RRGGBB" as a TColor.

There are also several conversionroutines to transform R,G,B to TColor IIRC.
From Graphics unit: function RGBToColor(R, G, B: Byte): TColor;


Bart
« Last Edit: March 21, 2018, 04:56:20 pm by Bart »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Problem setting UI component color to 'Orange'
« Reply #4 on: March 21, 2018, 04:55:17 pm »
endianess? try using the rgbtocolor function or if you are on windows my freeware color picker utility. https://github.com/taazz/EvsSimpleGraph/releases/download/v1/ColorUtil.exe
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

WooBean

  • Full Member
  • ***
  • Posts: 229
Re: Problem setting UI component color to 'Orange'
« Reply #5 on: March 21, 2018, 04:59:04 pm »
Try this value: $0000A5FF 
               BLUE GREEN RED
WooBean
Platforms: Win7/64, Linux Mint Ulyssa/64

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Re: Problem setting UI component color to 'Orange'
« Reply #6 on: March 21, 2018, 05:02:55 pm »
$00A5FF has got it.

I guessed it was an RGB order thing, and thought I'd tried all combinations but obviously missed that order.

Oddly I also tried using various 0000FF and 00FF00 type combinations to try to figure out the RGB order and it seemed to be red first then green then blue!

Tazz's endianess suggestion could be the clue, then, unless I was just getting really really confused.

-FM

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • My goal: build my own game engine using Lazarus
Re: Problem setting UI component color to 'Orange'
« Reply #7 on: March 21, 2018, 05:59:41 pm »
In my Graphics.pp line #265, you can see

Code: Pascal  [Select][+][-]
  1.   // standard colors
  2.   clBlack   = TColor($000000);
  3.   clMaroon  = TColor($000080);
  4.   clGreen   = TColor($008000);
  5.   clOlive   = TColor($008080);
  6.   clNavy    = TColor($800000);
  7.   clPurple  = TColor($800080);
  8.   clTeal    = TColor($808000);
  9.   clGray    = TColor($808080);
  10.   clSilver  = TColor($C0C0C0);
  11.   clRed     = TColor($0000FF);
  12.   clLime    = TColor($00FF00);
  13.   clYellow  = TColor($00FFFF);
  14.   clBlue    = TColor($FF0000);
  15.   clFuchsia = TColor($FF00FF);
  16.   clAqua    = TColor($FFFF00);
  17.   clLtGray  = TColor($C0C0C0); // clSilver alias
  18.   clDkGray  = TColor($808080); // clGray alias
  19.   clWhite   = TColor($FFFFFF);

So it is clear, the TColor is using BGR order at least on my Gtk2 Linux.

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Re: Problem setting UI component color to 'Orange'
« Reply #8 on: March 21, 2018, 09:21:53 pm »
I had obviously just completely tied myself in knots, in that case.

I had even hovered over some of the defined colours (clRed, clLime etc) to see which character pairs corresponded with the red, green and blue amounts!

Thanks for clarifying and putting me right.

(Does make you wonder why orange isn't a standard colour, though...)

-Dan

Thaddy

  • Hero Member
  • *****
  • Posts: 14164
  • Probably until I exterminate Putin.
Re: Problem setting UI component color to 'Orange'
« Reply #9 on: March 21, 2018, 10:39:13 pm »
Cross the Dutch border maybe? :P We have no problem with Orange. Maybe your laptop starts to behave.... :o %) %) %)
« Last Edit: March 21, 2018, 10:40:55 pm by Thaddy »
Specialize a type, not a var.

 

TinyPortal © 2005-2018