Color red,green,blue
Parameters
|
red - red component, 0 to 255 green - green component, 0 to 255 blue - blue component, 0 to 255 |
Description
|
Sets the drawing colour for all following drawing commands. Plot, Line, Rect, Oval, Text and the Print family all draw in the current colour until you change it. Mix any colour from red, green and blue at 0-255 each: Color 255,255,255 is white, Color 255,0,0 pure red, Color 255,200,0 a warm gold. After Graphics the colour starts as white. It does not affect images - DrawImage draws an image's own pixels - and Cls has its own colour, set with ClsColor. You can read the current colour back with ColorRed(), ColorGreen() and ColorBlue(), or set it from a pixel on screen with GetColor. Since every draw uses the one current colour, functions that draw in their own colours should set what they need rather than assume - stray Color calls are a classic source of "why is my text green?". See also: ClsColor, GetColor, ColorRed, ColorGreen, ColorBlue. |
Example
; Color Example ; ------------- Graphics 640,480,0,2 SetBuffer BackBuffer() red=255 green=128 blue=0 While Not KeyDown(1) Cls ; Hold R / G / B to raise a component; hold Shift as well to lower it d=2 If KeyDown(42) Then d=-2 If KeyDown(19) Then red=red+d If KeyDown(34) Then green=green+d If KeyDown(48) Then blue=blue+d If red<0 Then red=0 If red>255 Then red=255 If green<0 Then green=0 If green>255 Then green=255 If blue<0 Then blue=0 If blue>255 Then blue=255 ; Color sets the drawing colour for everything that follows Color red,green,blue ; A swatch, a ring and a line - all in the mixed colour Rect 220,140,200,200,1 Oval 180,100,280,280,0 Line 0,460,639,460 Color 255,255,255 Text 0,0,"Hold R / G / B to mix (add Shift to lower) Esc: exit" Text 0,20,"Color "+red+","+green+","+blue Flip Wend End
Index