-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1692 from Drofseh/colour-conversion
Common - Add color conversion functions
- Loading branch information
Showing
12 changed files
with
415 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_colorAHEXtoDecimal | ||
Description: | ||
Converts a hexidecimal coded color with transparency to the ingame decimal color format. | ||
Parameters: | ||
_hexString - A hexidecimal color code, "AARRGGBB" with or without a leading # <STRING> | ||
Returns: | ||
Ingame color format <ARRAY> | ||
Examples: | ||
(begin example) | ||
"AABA2619" call CBA_fnc_colorAHEXtoDecimal | ||
(end) | ||
Author: | ||
Lambda.Tiger & drofseh | ||
---------------------------------------------------------------------------- */ | ||
SCRIPT(colorAHEXtoDecimal); | ||
|
||
params [["_hexString", "FF000000", [""]]]; | ||
|
||
_hexString = ((toUpperANSI _hexString) trim ["#", 0]) regexReplace ["[^0-9A-F]", "0"]; | ||
|
||
private _values = _hexString splitString ""; | ||
|
||
[ | ||
call compile ("0x"+_values#2+_values#3), | ||
call compile ("0x"+_values#4+_values#5), | ||
call compile ("0x"+_values#6+_values#7), | ||
call compile ("0x"+_values#0+_values#1) | ||
] call CBA_fnc_colorRGBAtoDecimal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_colorARGBtoDecimal | ||
Description: | ||
Converts an ARGB coded color with transparency to the ingame decimal color format. | ||
Parameters: | ||
_alpha - The alpha/transparency channel, 0-255 <NUMBER> | ||
_red - The red channel, 0-255 <NUMBER> | ||
_green - The green channel, 0-255 <NUMBER> | ||
_blue - The blue channel, 0-255 <NUMBER> | ||
Returns: | ||
Ingame color format <ARRAY> | ||
Examples: | ||
(begin example) | ||
[255,186,38,25] call CBA_fnc_colorARGBtoDecimal | ||
(end) | ||
Author: | ||
drofseh & Lambda.Tiger | ||
---------------------------------------------------------------------------- */ | ||
SCRIPT(colorARGBtoDecimal); | ||
|
||
params [["_alpha", 255, [0]],["_red", 0, [0]],["_green", 0, [0]],["_blue", 0, [0]]]; | ||
[_red,_green,_blue,_alpha] apply {(0 max _x min 255)/255} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_colorHEXAtoDecimal | ||
Description: | ||
Converts a hexidecimal coded color with transparency to the ingame decimal color format. | ||
Parameters: | ||
_hexString - A hexidecimal color code, "RRGGBBAA" with or without a leading # <STRING> | ||
Returns: | ||
Ingame color format <ARRAY> | ||
Examples: | ||
(begin example) | ||
"BA2619AA" call CBA_fnc_colorHEXAtoDecimal | ||
(end) | ||
Author: | ||
Lambda.Tiger & drofseh | ||
---------------------------------------------------------------------------- */ | ||
SCRIPT(colorHEXAtoDecimal); | ||
|
||
params [["_hexString", "000000FF", [""]]]; | ||
|
||
_hexString = ((toUpperANSI _hexString) trim ["#", 0]) regexReplace ["[^0-9A-F]", "0"]; | ||
|
||
private _values = _hexString splitString ""; | ||
|
||
[ | ||
call compile ("0x"+_values#0+_values#1), | ||
call compile ("0x"+_values#2+_values#3), | ||
call compile ("0x"+_values#4+_values#5), | ||
call compile ("0x"+_values#6+_values#7) | ||
] call CBA_fnc_colorRGBAtoDecimal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_colorHEXtoDecimal | ||
Description: | ||
Converts a hexidecimal coded color without transparency to the ingame decimal color format. | ||
Parameters: | ||
_hexString - A hexidecimal color code, "RRGGBB" with or without a leading # <STRING> | ||
Returns: | ||
Ingame color format <ARRAY> | ||
Examples: | ||
(begin example) | ||
"BA2619" call CBA_fnc_colorHEXtoDecimal | ||
(end) | ||
Author: | ||
Lambda.Tiger & drofseh | ||
---------------------------------------------------------------------------- */ | ||
SCRIPT(colorHEXtoDecimal); | ||
|
||
params [["_hexString", "000000", [""]]]; | ||
|
||
_hexString = ((toUpperANSI _hexString) trim ["#", 0]) regexReplace ["[^0-9A-F]", "0"]; | ||
|
||
private _values = _hexString splitString ""; | ||
|
||
[ | ||
call compile ("0x"+_values#0+_values#1), | ||
call compile ("0x"+_values#2+_values#3), | ||
call compile ("0x"+_values#4+_values#5) | ||
] call CBA_fnc_colorRGBtoDecimal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_colorRGBAtoDecimal | ||
Description: | ||
Converts an RGBA coded color with transparency to the ingame decimal color format. | ||
Parameters: | ||
_red - The red channel, 0-255 <NUMBER> | ||
_green - The green channel, 0-255 <NUMBER> | ||
_blue - The blue channel, 0-255 <NUMBER> | ||
_alpha - The alpha/transparency channel, 0-255 <NUMBER> | ||
Returns: | ||
Ingame color format <ARRAY> | ||
Examples: | ||
(begin example) | ||
[186,38,25,255] call CBA_fnc_colorRGBAtoDecimal | ||
(end) | ||
Author: | ||
drofseh & Lambda.Tiger | ||
---------------------------------------------------------------------------- */ | ||
SCRIPT(colorRGBAtoDecimal); | ||
|
||
params [["_red", 0, [0]],["_green", 0, [0]],["_blue", 0, [0]],["_alpha", 255, [0]]]; | ||
[_red,_green,_blue,_alpha] apply {(0 max _x min 255)/255} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_colorRGBtoDecimal | ||
Description: | ||
Converts an RGB coded color without transparency to the ingame decimal color format. | ||
Parameters: | ||
_red - The red channel, 0-255 <NUMBER> | ||
_green - The green channel, 0-255 <NUMBER> | ||
_blue - The blue channel, 0-255 <NUMBER> | ||
Returns: | ||
Ingame color format <ARRAY> | ||
Examples: | ||
(begin example) | ||
[186,38,25] call CBA_fnc_colorRGBtoDecimal | ||
(end) | ||
Author: | ||
drofseh & Lambda.Tiger | ||
---------------------------------------------------------------------------- */ | ||
SCRIPT(colorRGBtoDecimal); | ||
|
||
params [["_red", 0, [0]],["_green", 0, [0]],["_blue", 0, [0]]]; | ||
[_red,_green,_blue] apply {(0 max _x min 255)/255} |
Oops, something went wrong.