Skip to content

Latest commit

 

History

History
189 lines (164 loc) · 4.99 KB

color.md

File metadata and controls

189 lines (164 loc) · 4.99 KB

Color

defined in file

banded/draft.scad
|
+--> banded/draft_color.scad
. . .

<-- file overview
<-- table of contents

Contents

Convert colors ^

get_color ^

Return the color as rgb or rgba list from different color arguments.
The color argument is the same like OpenSCAD module color()

get_color (c, alpha, default)
  • c - color argument
  • alpha - optional, alpha value - transparent to opaque: 0...1, default = 1.
  • default - optional, default color if c is not set, default = not set

Color arguments:

  • color name as string
    • The color names are taken from the World Wide Web consortium's SVG color list.
    • Additional defined colors
  • color as rgb or rgba list
  • rgb - as list [r, g, b] or [r, g, b, alpha]
    • r = red: 0...1
    • g = green: 0...1
    • b = blue: 0...1
    • alpha = transparent to opaque: 0...1, default = 1
  • color as hex string
    • Every hex string begin with a #
    • The letters are hexadicimal numbers 0-F (or even 00-FF)
    • Hex string formats:
      • "#rgb"
      • "#rgba"
      • "#rrggbb"
      • "#rrggbbaa"

Return list:

  • [r, g, b, alpha]
    • r = red: 0...1
    • g = green: 0...1
    • b = blue: 0...1
    • alpha = transparent to opaque: 0...1, default = 1

Additional defined colors:

  • metal:
    • "aluminium"
    • "brass"
    • "oldbrass"
    • "copper"
    • "iron"
    • "stainless"
    • "steel"
    • "chrome"
    • "zinc"
  • wood:
    • "birch"
    • "oak"
    • "pine"

color_hsv_to_rgb ^

Transform color from hsv model to rgb model.

Arguments:

color_hsv_to_rgb (hsv, alpha)
  • hsv - as list [h, s, v] or [h, s, v, alpha]
    • h = hue: 0...360°
    • s = saturation: 0...1
    • v = value, brightness: 0...1
    • alpha = transparent to opaque: 0...1, default = 1
  • return list [r, g, b, alpha]
    • r = red: 0...1
    • g = green: 0...1
    • b = blue: 0...1

color_rgb_to_hsv ^

Transform color from rgb model to hsv model.

Arguments:

color_rgb_to_hsv (rgb, alpha)
  • rgb - as list [r, g, b] or [r, g, b, alpha]
    • r = red: 0...1
    • g = green: 0...1
    • b = blue: 0...1
    • alpha = transparent to opaque: 0...1, default = 1
  • return list [h, s, v, alpha]
    • h = hue: 0...360°
    • s = saturation: 0...1
    • v = value, brightness: 0...1

color_list_to_hex ^

Convert a rgb color list to a hex value string.

Arguments:

color_list_to_hex (rgb, alpha)
  • rgb - as list [r, g, b] or [r, g, b, alpha]
    • r = red: 0...1
    • g = green: 0...1
    • b = blue: 0...1
    • alpha = transparent to opaque: 0...1, default = 1

color_hex_to_list ^

Convert a hex color string to a rgb color list.

Arguments:

color_hex_to_list (hex, alpha)

Description: It can be used the same hex values like for OpenSCAD module color().

  • optional alpha value - transparent to opaque: 0...1, default = 1
  • Every hex string begin with a #
  • The letters are hexadicimal numbers 0-F (or even 00-FF)

Hex string formats:

  • "#rgb"

  • "#rgba"

  • "#rrggbb"

  • "#rrggbbaa"

  • r = red: 0-F (or even 00-FF)

  • g = green: 0-F

  • b = blue: 0-F

  • a = alpha value, transparent to opaque: 0-F, default = F or FF

color_name ^

Return the name of color to rgb value as list.
The color names are taken from the World Wide Web consortium's SVG color list. Contains additional defined colors, see get_color().

Arguments:

color_name (name, alpha)
  • alpha - optional alpha value - transparent to opaque: 0...1, default = 1.

color_brightness ^

Return the brightness of a color from rgb list.

Arguments:

color_brightness (rgb, gamma)
  • rgb - as list [r, g, b]
    • r = red: 0...1
    • g = green: 0...1
    • b = blue: 0...1
  • gamma - the gamma correctur factor, optional
  • return a value of brightness 0...1
    • 0 = black
    • 1 = white