|
LifeLua 21-08-2025
Documentation for LifeLua, a Lua interpreter for the PS Vita
|
Creating and changing colors. More...
A color is a value holding red, green, blue and alpha (opacity), each from 0 to 255. Create one with color.new() and pass it to any function that draws something.
Colors are never changed in place: functions like color.r() or color.add() return a new color.
You can also call these functions as methods, and use +, - and == on colors:
Functions | |
| color | color.new (number r, number g, number b, number a) |
| number | color.r (color color, number r) |
| number | color.g (color color, number g) |
| number | color.b (color color, number b) |
| number | color.a (color color, number a) |
| color | color.add (color color1, color color2) |
| color | color.sub (color color1, color color2) |
| color | color.blend (color color1, color color2) |
| color | color.mix (color color1, color color2, number p1, number p2) |
| color | tocolor (number color) |
| number color.a | ( | color | color, |
| number | a ) |
Gets the alpha (opacity) of a color, or makes a copy of the color with a different alpha
Also available as a method: c:a() / c:a(value)
| color | The color |
| a | New alpha value, 0-255 (optional) |
a is omitted, otherwise a new color with the changed alpha | color color.add | ( | color | color1, |
| color | color2 ) |
Adds two colors together, channel by channel (results are capped at 255)
Also available as color1 + color2 and color1:add(color2)
| color1 | First color |
| color2 | Second color |
| number color.b | ( | color | color, |
| number | b ) |
Gets the blue value of a color, or makes a copy of the color with a different blue value
Also available as a method: c:b() / c:b(value)
| color | The color |
| b | New blue value, 0-255 (optional) |
b is omitted, otherwise a new color with the changed blue value | color color.blend | ( | color | color1, |
| color | color2 ) |
Blends two colors evenly (50% of each)
Also available as a method: color1:blend(color2)
| color1 | First color |
| color2 | Second color |
| number color.g | ( | color | color, |
| number | g ) |
Gets the green value of a color, or makes a copy of the color with a different green value
Also available as a method: c:g() / c:g(value)
| color | The color |
| g | New green value, 0-255 (optional) |
g is omitted, otherwise a new color with the changed green value | color color.mix | ( | color | color1, |
| color | color2, | ||
| number | p1, | ||
| number | p2 ) |
Mixes two colors using a weight for each. The weights don't need to add up to 100, they are relative to each other (3, 1 gives 75% of color1 and 25% of color2).
Also available as a method: color1:mix(color2, p1, p2)
| color1 | First color |
| color2 | Second color |
| p1 | Weight of the first color |
| p2 | Weight of the second color |
| color color.new | ( | number | r, |
| number | g, | ||
| number | b, | ||
| number | a ) |
Creates a new color. Values outside of 0-255 are clamped.
| r | Red, 0-255 |
| g | Green, 0-255 |
| b | Blue, 0-255 |
| a | Alpha (opacity), 0 is invisible and 255 is fully visible (optional, default: 255) |
| number color.r | ( | color | color, |
| number | r ) |
Gets the red value of a color, or makes a copy of the color with a different red value
Also available as a method: c:r() / c:r(value)
| color | The color |
| r | New red value, 0-255 (optional) |
r is omitted, otherwise a new color with the changed red value | color color.sub | ( | color | color1, |
| color | color2 ) |
Subtracts the second color from the first, channel by channel (results are capped at 0)
Also available as color1 - color2 and color1:sub(color2)
| color1 | Color to subtract from |
| color2 | Color to subtract |
| color tocolor | ( | number | color | ) |
Converts a number to a color. The number is read in 0xAABBGGRR order: alpha, blue, green, red (the reverse of the usual HTML order).
Any function that takes a color also accepts such a number directly.
| color | The color as a number |