Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

GGColour makes it very simple to used named or hex colours in your game or app. You can also create custom colour palettes that you can swap out whenever you want. Colour values liberated from here - http://www.tayloredmktg.com/rgb/

branch: master
README.md

GGColour

GGColour makes it very simple to used named or hex colours in your game or app. You can also create custom colour palettes that you can swap out whenever you want. Colour values liberated from here - http://www.tayloredmktg.com/rgb/

Basic Usage

Require the code
local GGColour = require( "GGColour" )
Create your chart
local colourChart = GGColour:new()
Load up some colors. The 'otherRGB.json' set is included with this library.
colourChart:loadColours( "otherRGB.json" )
Save out the current colours to a file.
colourChart:saveColours( "customColours.json" )
Get a named colour
local r, g, b, a = colourChart:fromName( "ForestGreen" )
Get a named colour as a table
local colour = colourChart:fromName( "Tomato", true )
Use a named colour for a display object
local back = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
back:setFillColor( colourChart:fromName( "Tomato" ) )
Use a hex colour for a display object
local back = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
back:setFillColor( colourChart:fromHex( "6495ed" ) )
Use a gradient for a display object
local gradient = graphics.newGradient( colourChart:fromName( "SkyBlue", true ), colourChart:fromName( "MidnightBlue", true ), "up" )
local back = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
back:setFillColor( gradient )
Create a colour palette
local palette = {}
palette[ "red" ] = colourChart:fromName( "Tomato", true )
palette[ "green" ] = colourChart:fromName( "ForestGreen", true )
palette[ "blue" ] = colourChart:fromHex( "6495ed", true )
colourChart:addPalette( "default", palette )
Load a colour palette from a file
colourChart:loadPalette( "sample", "samplePalette.json" )
Use a named colour from a palette for a display object
local back = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
back:setFillColor( colourChart:fromName( "red", false, "default" ) )
Print out all available named colours
for name, rgb in pairs( colourChart:getAvailableColours() ) do
    print( name, "R: " .. rgb[ 1 ] .. ", G: " .. rgb[ 2 ] .. ", B: " .. rgb[ 3 ] )
end
Destroy the colour chart
colourChart:destroy()
colourChart = nil
Something went wrong with that request. Please try again.