ColorRed ( )
Parameters
| None. |
Description
|
Returns the red component of the current drawing colour, 0 to 255. The current colour is whatever the last Color set - or, after GetColor, the colour picked up from the screen. That makes ColorRed(), ColorGreen() and ColorBlue() the way to read GetColor's result: point GetColor at a pixel, then read the three components. Also handy for saving the colour before a routine changes it: stash the three components, draw, then restore with Color. See also: ColorGreen, ColorBlue, Color, GetColor. |
Example
; ColorRed Example ; ---------------- Graphics 640,480,0,2 SetBuffer BackBuffer() angle#=0 While Not KeyDown(1) Cls ; Smoothly cycle the drawing colour through a rainbow angle=angle+1 Color 128+Sin(angle)*127,128+Sin(angle+120)*127,128+Sin(angle+240)*127 ; Draw a swatch in the current drawing colour Rect 220,120,200,200,1 ; ColorRed reads back the red part of the current drawing colour r=ColorRed() ; Bar showing just the red component Color 255,0,0 Rect 20,420,r,20,1 Rect 20,420,256,20,0 Color 255,255,255 Text 0,0,"Esc: exit" Text 0,20,"ColorRed() = "+r Flip Wend End
Index