Difference between revisions of "RGBToColor"
From SCAR Divi Manual
(→Example 1) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Definition== | ==Definition== | ||
<source lang="scar" lines="false"> | <source lang="scar" lines="false"> | ||
− | function | + | function RGBToColor(R, G, B: Integer): Integer; |
</source> | </source> | ||
===Source Code=== | ===Source Code=== | ||
<source lang="scar"> | <source lang="scar"> | ||
− | function | + | function RGBToColor(R, G, B: Integer): Integer; |
begin | begin | ||
Result := R or (G shl 8) or (B shl 16); | Result := R or (G shl 8) or (B shl 16); | ||
Line 16: | Line 16: | ||
==Description== | ==Description== | ||
− | Converts RGB values specified by '''R''', '''G''' and '''B''' to a regular color value. The result can be split back into RGB values using [[ColorToRGB]]. | + | Converts [http://en.wikipedia.org/wiki/RGB_color_model RGB] values specified by '''R''', '''G''' and '''B''' to a regular color value. The result can be split back into RGB values using [[ColorToRGB]]. |
==Example 1== | ==Example 1== | ||
<source lang="scar"> | <source lang="scar"> | ||
begin | begin | ||
− | WriteLn( | + | WriteLn(RGBToColor(0, 0, 0)); |
− | WriteLn( | + | WriteLn(RGBToColor(255, 0, 0)); |
− | WriteLn( | + | WriteLn(RGBToColor(0, 255, 0)); |
− | WriteLn( | + | WriteLn(RGBToColor(0, 0, 255)); |
− | WriteLn( | + | WriteLn(RGBToColor(255, 255, 255)); |
end. | end. | ||
</source> | </source> | ||
Line 59: | Line 59: | ||
[[Category:Functions]] | [[Category:Functions]] | ||
− | [[Category: | + | [[Category:Color Functions]] |
+ | [[Category:Conversion Functions]] |
Latest revision as of 17:39, 3 July 2011
Contents
Definition
function RGBToColor(R, G, B: Integer): Integer;
Source Code
function RGBToColor(R, G, B: Integer): Integer; begin Result := R or (G shl 8) or (B shl 16); end;
Availability
SCAR Divi 3.00 > Current
Description
Converts RGB values specified by R, G and B to a regular color value. The result can be split back into RGB values using ColorToRGB.
Example 1
begin WriteLn(RGBToColor(0, 0, 0)); WriteLn(RGBToColor(255, 0, 0)); WriteLn(RGBToColor(0, 255, 0)); WriteLn(RGBToColor(0, 0, 255)); WriteLn(RGBToColor(255, 255, 255)); end.
Output:
0 255 65280 16711680 16777215
Example 2
var c, r, g, b: Integer; begin c := RGBToColor(1, 25, 127); WriteLn(c); ColorToRGB(c, r, g, b); WriteLn(IntToStr(r) + ',' + IntToStr(g) + ',' + IntToStr(b)); end.
Output:
8329473 1,25,127