Colours
The Colours
keyword gives you access to predefined colour and functions to interpolate and modify colours in a ScriptPanels
g
context.
const var Panel1 = Content.getComponent("Panel1");
Panel1.setPaintRoutine(function(g)
{
g.setColour(Colours.fromVec4([0.7,0,1,1])); // [r,g,b,a] float array.
g.fillEllipse([0,0,50,50]);
g.setColour(Colours.mix(Colours.blue, Colours.red, 0.7)); // interpolates between two colors
g.fillEllipse([55,0,50,50]);
g.setColour(Colours.withHue(Colours.saddlebrown, 0.1)); // interpolates through the whole hue cycle from 0-1
g.fillEllipse([110,0,50,50]);
g.setColour(Colours.withAlpha(0xAAAAAAAA, 0.2)); // sets the colours alpha transparency
g.fillEllipse([0,55,50,50]);
g.setColour(Colours.withBrightness(0xAAAAAAAA, 0.6)); // sets the brightness
g.fillEllipse([55,55,50,50]);
g.setColour(Colours.withSaturation(0xAAAAAAAA, 0.6)); // set the saturation
g.fillEllipse([110,55,50,50]);
g.setColour(Colours.withMultipliedAlpha(0xAAAAAAAA, 0.2)); // sets a multiplied alpha value
g.fillEllipse([0,110,50,50]);
g.setColour(Colours.withMultipliedBrightness(0xAAAAAAAA, 0.6)); // sets a multiplied brightness
g.fillEllipse([55,110,50,50]);
g.setColour(Colours.withMultipliedSaturation(0xAAAAAAAA, 0.6)); // sets a multiplied saturation.
g.fillEllipse([110,110,50,50]);
});
Class methods
fromVec4
Converts a colour from a [r, g, b, a] float array to a uint32 value. Edit on GitHub
Colours.fromVec4(var vec4)
mix
Linear interpolation between two colours. Edit on GitHub
Colours.mix(var colour1, var colour2, float alpha)
toVec4
Converts a colour to a [r, g, b, a] array that can be passed to GLSL as vec4.
Colours.toVec4(var colour)
Console.print(trace(Colours.toVec4(Colours.saddlebrown)));
withAlpha
Returns a colour value with the specified alpha value. Edit on GitHub
Colours.withAlpha(var colour, float alpha)
withBrightness
Returns a colour with the specified brightness. Edit on GitHub
Colours.withBrightness(var colour, float brightness)
withHue
Returns a colour with the specified hue. Edit on GitHub
Colours.withHue(var colour, float hue)
withMultipliedAlpha
Returns a colour with a multiplied alpha value. Edit on GitHub
Colours.withMultipliedAlpha(var colour, float factor)
withMultipliedBrightness
Returns a colour with a multiplied brightness value. Edit on GitHub
Colours.withMultipliedBrightness(var colour, float factor)
withMultipliedSaturation
Returns a colour with a multiplied saturation value. Edit on GitHub
Colours.withMultipliedSaturation(var colour, float factor)
withSaturation
Returns a colour with the specified saturation. Edit on GitHub
Colours.withSaturation(var colour, float saturation)