User Tools

Site Tools


en:color

Color (Statement)

Format

color color
color ( color )
color pen_color, brush_color
color ( pen_color, brush_color )

Description

Sets the current drawing color to colorname or to an ARGB value where ((a * 256 + r) * 256 + g) * 256 + b. If a single color is specified both the pen and the brush will be set to the same color. There are several ways to define a color in BASIC256:

  1. one of the defined color constants (see table below);
  2. an integer to define the color where ((a * 256 + r) * 256 + g) * 256 + b,
    • a - transparency 0 = transparent to 255 = opaque
    • r - red 0 = off to 255 = full on
    • g - green 0 = off to 255 = full on
    • b - blue 0 = off to 255 = full on
  3. the rgb function passing it 3 or 4 numbers from 0-255,
  4. using an svg color name as a string as defined by the W3C,
  5. or using a string with a “#” followed by 6 or 8 hexadecimal digits (“#ff0000”, “#a0ffffff”)

When drawing solid shapes (Chord,Circle,Pie,Poly,Rect, and Stamp) the border of the shape will be drawn with the pen color and the shape itself will be filled with the brush color. A brush color of CLEAR is used to not fill a closed shape.

If the current pen and brush are both set to CLEAR the pixels or shapes drawn will clear the pixels of the graphics output area and make them transparent. This is especially useful when creating sprites using the Spriteslice command.

Color Constant (Name)ARGB ValuesInteger
BLACK255, 0, 0, 04278190080Black
WHITE255, 255, 255, 2554294506744White
RED255, 255, 0, 04294901760red
DARKRED255, 128, 0, 04286578688darkred
GREEN255, 0, 255, 04278255360green
DARKGREEN255, 0, 128, 04278222848darkgreen
BLUE255, 0, 0, 2554278190335blue
DARKBLUE255, 0, 0, 1284278190208darkblue
CYAN255, 0, 255, 2554278255615cyan
DARKCYAN255, 0, 128, 1284278222976darkcyan
PURPLE255, 255, 0, 2554294902015purple
DARKPURPLE255, 128, 0, 1284286578816darkpurple
YELLOW255, 255, 255, 04294967040yellow
DARKYELLOW255, 128, 128 ,04286611456darkyellow
ORANGE255, 255, 102, 04294927872orange
DARKORANGE255, 176, 61 ,04289344256darkorange
GREY255, 164, 164 ,1644288980132grey
DARKGREY255, 128, 128 ,1284286611584darkgrey
CLEAR0, 0, 0, 00
2016/08/12 21:00 · admin

Deprecated Form

In version 0.9.9.26 the statement form “color red, blue, green” or “color ( red, blue, green )” was deprecated and a warning will be displayed when it is encountered. It should be replaced with “color rgb ( red, blue, green )”.

Example

clg
color rgb(128,128,128)
rect 0,0,graphwidth, graphheight

penwidth 5
color green,red
circle 100,100,50

penwidth 1
color rgb(255,160,160)
circle 100,100,25

penwidth 5
color "firebrick","#fab856"
rect 150,150,100,100

color "papayawhip", "clear"
rect 175,175,100,100

Will draw the following:
Color

See Also

2016/01/01 22:42

History

0.9.5madded “COLOR r,g,b” form and numeric representation of color names
0.9.9.26Added brush color and deprecated the “COLOR r,g,b”.
0.9.9.28Changed color values to include Alpha (transparency) and changed color constants to new ARGB values.
0.9.9.45changed values to positive numbers following formula as documented.
2.0.99.4Added ability to use string names and hex values for colors.
en/color.txt · Last modified: 2020/11/22 21:26 by admin