Color Object

With this object you can easily modify and/or convert colors.

  • HL.Color:New(params)
  • ColorObj:Brighten(delta)
  • ColorObj:Clone()
  • ColorObj:Darken(delta)
  • ColorObj:fromARGB(a, r, g, b)
  • ColorObj:fromValue(value)
  • ColorObj:toARGBValue()
  • ColorObj:toRGBValue()

Creation

HL.Color:New(params)

ColorObj = HL.Color:New(params)

Creates a new color object

INPUT

  • params : An optional table with one or more members as follow:
    → r : Red component
    → g : Green component
    → b : Blue component
    → a : Transparency level

OUTPUT

  • ColorObj : A new color object

Methods

HL.Color:Brighten(delta)

HL.Color:Brighten(delta)

Make the current color brighten by a given factor represented by 'delta'

INPUT

  • delta : Amount in units to add to all current color's components


HL.Color:Clone()

ColorObj = HL.Color:Clone()

Clone the color to a new object

OUTPUT

  • ColorObj : The clones color object


HL.Color:Darken(delta)

HL.Color:Darken(delta)

Make the current color darker by a given factor represented by 'delta'

INPUT

  • delta : Amount in units to subtract from all current color's components


HL.Color:fromARGB(a, r, g, b)

HL.Color:fromARGB(a, r, g, b)

Load the color object with the given A, R, G, B components

INPUT

  • a : Alpha component
  • r : Red component
  • g : Green component
  • b : Blue component


HL.Color:fromValue(value)

HL.Color:fromValue(value)

Load the color object with the given color value

INPUT

  • value : The color value to load into the object


HL.Color:toARGBValue()

value = HL.Color:toARGBValue()

Returns the ARGB color value

OUTPUT

  • value : ARGB color value stored in the color object


HL.Color:toRGBValue()

value = HL.Color:toRGBValue()

Returns the RGB color value

OUTPUT

  • value : RGB color value stored in the color object

Object Structure

Each color object have the following structure :

HL.Color =
  { r = 0,         ; Red component (default = 0)
    g = 0,         ; Green component (default = 0)
    b = 0,         ; Blue component (default = 0)
    a = 0          ; Alpha component (default = 0 -> full opaque)
    }
hollywoodlibs/helpers/color.txt · Ultima modifica: 2016/10/21 19:30 da admin
CC Attribution-Noncommercial 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0