meta data for this page
  •  

This is an old revision of the document!


Color

Shapes can exhibit different colors. And just like the other transformations, adding color to a shape produces a new shape, i.e. one with color.

let myshape = colorize([1, 0, 0], sphere()) // RGB red
let myshape = colorize([1, 0.5, 0.3], sphere()) // color
let myshape = colorize([1, 0.5, 0.3, 0.6], sphere()) // color plus alpha transparency

Note: There are known issues with transparency, and depending on the order of colors, objects may not seem transparent. Try different 'alpha' values or colors.

Color Space Conversion

There are several functions to convert between color spaces, including color names.

let wildcylinder = colorize(colorNameToRgb('fuchsia'), cylinder())
 
let bluesphere = colorize(hexToRgb('#000080'), sphere()) // navy blue
 
let mysphere = colorize(hslToRgb([0.9166666666666666, 1, 0.5]), sphere())
 
let mysphere = colorize(hsvToRgb([0.9166666666666666, 1, 1]), sphere())

whereas

See the Extended Color Keywords for all available colors. Color keywords are case-insensitive, e.g. 'RED' is the same as 'red'.