02.12.2008, 06:48
About:
color.inc is a function library filled with colour manipulating functions. It includes a lot of smaller functions as a base for creating your own larger functions. It also includes color defines for the web colours (if you'd like to overwrite these colours then define them BEFORE the #include <color> line).
Function List
FunctionDescription
__________________________________________________ ________________________________________________
setRed(color, red)Returns the specified colour with the specified RED intensity.
setGreen(color, green)Returns the specified colour with the specified GREEN intensity.
setBlue(color, blue)Returns the specified colour with the specified BLUE intensity.
setAlpha(color, alpha)Returns the specified colour with the specified ALPHA intensity.
__________________________________________________ ________________________________________________
stripRed(color)Returns the specified colour with all RED stripped from it (0x00XXXXXX).
stripGreen(color)Returns the specified colour with all GREEN stripped from it (0xXX00XXXX).
stripBlue(color)Returns the specified colour with all BLUE stripped from it (0xXXXX00XX).
stripAlpha(color)Returns the specified colour with all ALPHA stripped from it (0xXXXXXX00).
__________________________________________________ ________________________________________________
fillRed(color)Returns the specified colour with filled RED (0xFFXXXXXX).
fillGreen(color)Returns the specified colour with filled GREEN (0xXXFFXXXX).
fillBlue(color)Returns the specified colour with filled BLUE (0xXXXXFFXX).
fillAlpha(color)Returns the specified colour with filled ALPHA (0xXXXXXXFF).
__________________________________________________ ________________________________________________
getRed(color)Returns the intensity of RED from the specified colour.
getGreen(color)Returns the intensity of GREEN from the specified colour.
getBlue(color)Returns the intensity of BLUE from the specified colour.
getAlpha(color)Returns the intensity of ALPHA from the specified colour.
__________________________________________________ ________________________________________________
makeColor(red, green, blue, alpha)Returns a new colour with the specified intensities.
setColor(color, red, green, blue, alpha)Returns an edited version of the specified colour with the specfied intensities. Use the NO_SET define to leave an intensity as it is. Note 1
Colour List:
This is a list of colour names defined inside the include, if you define your own colour with the same name before these then your colour will be the one that is used.
_COLOR_BLACK
_COLOR_NAVY
_COLOR_BLUE
_COLOR_GREEN
_COLOR_TEAL
_COLOR_LIME
_COLOR_AQUA
_COLOR_CYAN
_COLOR_MAROON
_COLOR_PURPLE
_COLOR_OLIVE
_COLOR_GRAY
_COLOR_GREY
_COLOR_SILVER
_COLOR_RED
_COLOR_FUCHSIA
_COLOR_PINK
_COLOR_YELLOW
_COLOR_WHITE
Notes:
Note 1: Usage of the setColor function can be demonstrated like this:
Note 2: Colour intensities can go from 0 (same as 0x00) to 255 (same as 0xFF).
Note 3: This has been tested but obviously not for every colour (and testing was limited due to %x not formatting correctly with larger numbers, functions were tested on a bitwise calculator though). If you do find a bug with it then please post the code you're using and the effect you think is bad and I'll look into it.
Download:
color.inc is a function library filled with colour manipulating functions. It includes a lot of smaller functions as a base for creating your own larger functions. It also includes color defines for the web colours (if you'd like to overwrite these colours then define them BEFORE the #include <color> line).
Function List
FunctionDescription
__________________________________________________ ________________________________________________
setRed(color, red)Returns the specified colour with the specified RED intensity.
setGreen(color, green)Returns the specified colour with the specified GREEN intensity.
setBlue(color, blue)Returns the specified colour with the specified BLUE intensity.
setAlpha(color, alpha)Returns the specified colour with the specified ALPHA intensity.
__________________________________________________ ________________________________________________
stripRed(color)Returns the specified colour with all RED stripped from it (0x00XXXXXX).
stripGreen(color)Returns the specified colour with all GREEN stripped from it (0xXX00XXXX).
stripBlue(color)Returns the specified colour with all BLUE stripped from it (0xXXXX00XX).
stripAlpha(color)Returns the specified colour with all ALPHA stripped from it (0xXXXXXX00).
__________________________________________________ ________________________________________________
fillRed(color)Returns the specified colour with filled RED (0xFFXXXXXX).
fillGreen(color)Returns the specified colour with filled GREEN (0xXXFFXXXX).
fillBlue(color)Returns the specified colour with filled BLUE (0xXXXXFFXX).
fillAlpha(color)Returns the specified colour with filled ALPHA (0xXXXXXXFF).
__________________________________________________ ________________________________________________
getRed(color)Returns the intensity of RED from the specified colour.
getGreen(color)Returns the intensity of GREEN from the specified colour.
getBlue(color)Returns the intensity of BLUE from the specified colour.
getAlpha(color)Returns the intensity of ALPHA from the specified colour.
__________________________________________________ ________________________________________________
makeColor(red, green, blue, alpha)Returns a new colour with the specified intensities.
setColor(color, red, green, blue, alpha)Returns an edited version of the specified colour with the specfied intensities. Use the NO_SET define to leave an intensity as it is. Note 1
Colour List:
This is a list of colour names defined inside the include, if you define your own colour with the same name before these then your colour will be the one that is used.
_COLOR_BLACK
_COLOR_NAVY
_COLOR_BLUE
_COLOR_GREEN
_COLOR_TEAL
_COLOR_LIME
_COLOR_AQUA
_COLOR_CYAN
_COLOR_MAROON
_COLOR_PURPLE
_COLOR_OLIVE
_COLOR_GRAY
_COLOR_GREY
_COLOR_SILVER
_COLOR_RED
_COLOR_FUCHSIA
_COLOR_PINK
_COLOR_YELLOW
_COLOR_WHITE
Notes:
Note 1: Usage of the setColor function can be demonstrated like this:
pawn Код:
new Color = 0xAABBCCDD;
Color = setColor( Color, 0xFF, 0x00, NO_SET, 0xEE ); // This will set the colour to 0xFF00CCEE (leaving the CC (blue intensity) from the original colour in place).
Note 3: This has been tested but obviously not for every colour (and testing was limited due to %x not formatting correctly with larger numbers, functions were tested on a bitwise calculator though). If you do find a bug with it then please post the code you're using and the effect you think is bad and I'll look into it.
Download: