Monday, 19 March 2012

Color names

Writing a graphical interface, Rebol permit you to write the color using a RGB tuple, like 0.0.0, or with the color name, like black.
Here a couple of example:

view layout [ button black "Click me" ]


view layout [ button 0.0.0 "Click me"]

Here the result:
 However there are a loot of colors memorized as a name in Rebol, here a script that help you to remember all:
Here the source:
    Title: "REBOL Standard Colors"
    Date: 31-Mar-2001
    Version: 1.0.2
    File: %color-names.r
    Author: ["Carl Sassenrath" "Massimiliano Vessi"]
    Purpose: "Displays the official built-in REBOL named colors."
colors:   [
    black   blue     navy   orange gold     tan
    coal   green   leaf   forest brown   coffee
    gray   cyan     teal   aqua   water   sky
    pewter red     maroon brick   crimson pink
    silver magenta purple violet papaya   rebolor
    snow   yellow   olive   oldrab khaki   mint
    white   ivory   linen   beige base-color
    reblue sienna wheat
sort colors
out: [
    style btn button font-size 11 100x38 [
    sc/color: face/color
    sc/text: reform ["Click a color to show it here ^/" face/text]
    show sc
cnt: 1
foreach color colors [
    repend out ['btn color reform [color newline get color]]
    if zero? cnt // 6 [append out 'return]
    cnt: cnt + 1
append out [
    sl: slider 208x38 "Multiplier" font [
        color: silver align: 'center valign: 'middle shadow: none][mult-color value ]
    sc: box 650x80 font-size 12 "Click a color to show it here" return
    button 650x40 black "Click here for custom color" [
        face/color: request-color/color any [face/color gray]
        face/texts: reduce [reform   face/color ]
        show face
mult-color: func [factor /local clr n m d] [
    n: 1
    m: max 1 to-integer factor - .5 * 8
    d: max 1 to-integer .5 - factor * 8
    sl/text: reform either factor > .5 [["times" m]][["divided by" d]]
    foreach color colors [
        clr: either factor > .5 [(get color) * m][(get color) / d]
        window/pane/:n/color: clr
        window/pane/:n/texts: reduce [reform [color newline clr]]
        n: n + 1
    show window
window: layout out
view window

The REBOL predefined color words, that you can use everywhere (VID, DRAW, script), are:

NameValueColor  NameValueColor
aqua40.100.130 base-color200.200.200 
beige255.228.196 black0.0.0 
blue0.0.255 brick178.34.34 
brown139.69.19 coal64.64.64 
coffee76.26.0 crimson220.20.60 
cyan0.255.255 forest0.48.0 
gold255.205.40 gray128.128.128 
green0.255.0 ivory255.255.240 
khaki179.179.126 leaf0.128.0 
linen250.240.230 magenta255.0.255 
maroon128.0.0 mint100.136.116 
navy0.0.128 oldrab72.72.16 
olive128.128.0 orange255.150.10 
papaya255.80.37 pewter170.170.170 
pink255.164.200 purple128.0.128 
reblue38.58.108 rebolor142.128.110 
red255.0.0 sienna160.82.45 
silver192.192.192 sky164.200.255 
snow240.240.240 tan222.184.135 
teal0.128.128 violet72.0.90 
water80.108.142 wheat245.222.129 
white255.255.255 yellow255.255.0 

No comments:

Post a Comment