Tuesday, June 2, 2009

Colors in Ax

When using Ax, sooner or later you gonna use your own colors. But different functions in Ax (and extensions) require different definitions of these colors.

There are different coding system for colors. Some functions require the hexadecimal format, others expect an integer and so on.
Luckily, Ax comes with some built in functions to do the necessary conversions for you. Like this one:

WinApi::RGB2int() - Convert the red, green and blue values to an integer.
WinApi::RGBCon2int() - Dito, but with a container input
WinApi::RGBInt2con() - The opposite, converting from an integer to separate red, green and blue values

Or create your own functions, like this one for example:

static str int2RGBhex(int color)
{ container colorcon;
str colorhex;
;
colorcon=WinApi::RGBint2Con(color);
colorhex=Global::int2Hex(conpeek(colorcon,1),2);

colorhex+=Global::int2Hex(conpeek(colorcon,2),2);
colorhex+=Global::int2Hex(conpeek(colorcon,3),2);

return colorhex;
}

This function will convert an integer color value to a hexadecimal one.

Happy coding,


Willy

No comments:

Post a Comment