- This wiki is out of date, use the continuation of this wiki instead
Rgbscale
From FenixWiki
(Difference between revisions)
| Revision as of 22:04, 13 April 2008 (edit) Sandman (Talk | contribs) (New page: Category:functions Category:graphical effects ==Definition== '''INT''' rgbscale ( <'''INT''' fileID> , <'''INT''' fraphID> , <'''FLOAT''' r> , <'''FLOAT''' g> , <'''FLOAT''' b> ) ...) ← Previous diff |
Current revision (19:12, 14 April 2008) (edit) (undo) Sandman (Talk | contribs) m (→Notes) |
||
| (2 intermediate revisions not shown.) | |||
| Line 5: | Line 5: | ||
| '''INT''' rgbscale ( <'''INT''' fileID> , <'''INT''' fraphID> , <'''FLOAT''' r> , <'''FLOAT''' g> , <'''FLOAT''' b> ) | '''INT''' rgbscale ( <'''INT''' fileID> , <'''INT''' fraphID> , <'''FLOAT''' r> , <'''FLOAT''' g> , <'''FLOAT''' b> ) | ||
| - | This will convert the specified | + | This will convert the specified [[graphic]] by using the specified color as a reference. The converted graphic will have only the specified color and lighter/darker colors; see [[#Notes|notes]] for the details. |
| == Parameters == | == Parameters == | ||
| Line 21: | Line 21: | ||
| == Returns == | == Returns == | ||
| - | '''INT''' | + | '''INT''' |
| + | {| | ||
| + | | -1 || - Invalid graphic. | ||
| + | |- | ||
| + | | 1 || - Success. | ||
| + | |} | ||
| == Errors == | == Errors == | ||
| Line 38: | Line 43: | ||
| </pre> | </pre> | ||
| where r,g,b are the specified r,g,b. | where r,g,b are the specified r,g,b. | ||
| + | |||
| + | Note that <code>[[rgbscale]](0,map,1,1,1) = [[grayscale]](0,map,0)</code>, for a valid graphic (0,map). | ||
| {{Funcbox | {{Funcbox | ||
| - | | category=Graphical | + | | category=Graphical effects |
| }} | }} | ||
Current revision
Contents |
[edit] Definition
INT rgbscale ( <INT fileID> , <INT fraphID> , <FLOAT r> , <FLOAT g> , <FLOAT b> )
This will convert the specified graphic by using the specified color as a reference. The converted graphic will have only the specified color and lighter/darker colors; see notes for the details.
[edit] Parameters
| INT fileID | - The fileID of the file that holds the graphics. |
| INT graphID | - The graphID of the graphic to convert. |
| FLOAT r | - The red component of the color to be used for reference. |
| FLOAT g | - The green component of the color to be used for reference. |
| FLOAT b | - The blue component of the color to be used for reference. |
[edit] Returns
INT
| -1 | - Invalid graphic. |
| 1 | - Success. |
[edit] Errors
| Unsupported color depth | - The graphic's color depth is not 16bit. |
[edit] Notes
The exact formula is:
for every pixel:
c = 0.3 * oldpixel_r + 0.59 * oldpixel_g + 0.11 * oldpixel_b
newpixel_r = r * c;
newpixel_g = g * c;
newpixel_b = b * c;
where r,g,b are the specified r,g,b.
Note that rgbscale(0,map,1,1,1) = grayscale(0,map,0), for a valid graphic (0,map).
| Graphical effects Functions | |
| • Blur() • Grayscale() • Rgbscale() • | |
