ColorHSB is 100% correct, was: does not seem to be giving correct output

Last night I was just going through to see a lot of what others have been doing with Amibroker. I came across a code that displays the ticker as part of the chart background which I thought was kind of cool. I tried playing around with it to try and change the color of it but didnt have much luck.

The first thing I did was try to figure out what colors used what settings by going to . It seemed to provide the correct setting but then when I went in to modify the AFL, I would keep getting something completely different. I tried even changing the order of the three parameters but still didnt have much luck getting the desired output. Any idea why this might be? Any suggestions?

GfxSelectFont("Tahoma", Status("pxheight")/8 );
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ColorHSB( 220, 54, 82 ) );
GfxSetBkMode(1); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/12 );
GfxSelectFont("Tahoma", Status("pxheight")/18 );
GfxTextOut( IndustryID(1), Status("pxwidth")/2, Status("pxheight")/4 );


@MCassICT, please, examine carefully how the "colorizer" displays the values in the HSL model.


They use an absolute value (0-255 for the Hue, but the next 2 values are expressed in percent).

AmiBroker ColorHSB() uses for all the 3 values a range 0, 255.

Each parameter ranges from 0 to 255, where 0 represents 0% saturation/brightness or 0 degree hue in HSV color wheel, and 255 represents 100% saturation/brightness or 360 degrees hue in HSV color wheel

Apply a correct calculation, and you'll get the desired color!

Anyway, to only change the color of the ticker name using ColorRGB() is probably simpler (or at least it is more intuitive for me). In this case you can simply use the 3 values of the "colorizer" as displayed, without any calculation.


That helped Thank you @beppe

1 Like

@MCassICT one very basic tip. Although I'm pretty sure that you already know that, it might be worth mentioning, that you can also easily fine-tune (using sliders) and see real-time how the output color changes directly in AFL. Just assign RGB components to one of Param functions. For instance:

C1 = Param("Red", 100, 0, 255, 1);
C2 = Param("Green", 150, 0, 255, 1);
C3 = Param("Blue", 200, 0, 255, 1);
GfxFillSolidRect (50, 50, 300, 300, ColorRGB(C1, C2, C3));



Excellent point @Milosz ! I hadn't even considered that. (Its funny that you just responded to this. I was actually just scrolling through all of your responses to other posts from your profile page because I am absolutely amazed at many of the things you suggest and contribute with