Colors Library (ssk.colors.*)

Easy Colors (ssk.colors.easy.*)

_WHITE_, _W_ _BLACK_, _K_ _TRANSPARENT_, _T_
_RED_, _R_ _GREEN_, _G_ _BLUE_, _B_
_LIGHTGREY_ _GREY_ _DARKGREY_
_CYAN_, _C_ _YELLOW_, _Y_ _ORANGE_, _O_
_PURPLE_ _PINK_, _P_

local circ = display.newCircle( 100, 100, 100 )

rect:setFillColor( unpack( _PURPLE_ ) )

Color Helpers and Utilities (ssk.colors.*)

Tip: These functions are exported as globals when SSK init() parameter exportColors is true.


local rect1 = display.newRect( 100, 100, 100, 100 )
local rect2 = display.newRect( 100, 100, 200, 100 )
local rect3 = display.newRect( 100, 100, 300, 100 )

-- Set fill color to a nice blue
rect1:setFillColor( unpack( hexcolor( "33AFFF" ) ) )

-- Choose a random Easy Color as the fill
rect2:setFillColor( unpack( randomColor() ) )

-- Set color to Graphics 1.0 encoded 'Pink'
rect3:setFillColor( unpack( rgba2( { 255, 0, 255 } ) ) )

RGB

(Graphcs 1.0 used values in the range [0,255].)

   local lightGrey = { 0.25, 0.25, 0.25, 1 }

RGB Functions (ssk.colors.*)

Tip: These functions are NOT exported and can only be accessed via ssk.colors.* or localizations.

HSL


   local cornFlowerBlue = hsl2rgb( 219, 0.79, 0.66, 1.0 )

HSL Functions (ssk.colors.*)

Tip: These functions are NOT exported and can only be accessed via ssk.colors.* or localizations.

Examples

RGB & HSL

Colors Example

function test.run( group, params )
   group = group or display.currentStage
   params = params or {}

   local startX = left + 100
   local startY = top + 100

   local curX = startX
   local curY = startY

   -- ==============================================
   -- Row 1 - Test conversions
    -- ==============================================

    -- RGB 2 HSL & HSL 2 RGB
    curX = startX
    local c = ssk.colors.rgb2hsl(_R_)
    local c2 = ssk.colors.hsl2rgb( c )
    newRect( group, curX, curY, { size = 80, fill = c2  } )

    curX = curX + 80
    local c = ssk.colors.rgb2hsl(_G_)
    local c2 = ssk.colors.hsl2rgb( c )
    newRect( group, curX, curY, { size = 80, fill = c2  } )

    curX = curX + 80
    local c = ssk.colors.rgb2hsl(_B_)
    local c2 = ssk.colors.hsl2rgb( c )
    newRect( group, curX, curY, { size = 80, fill = c2  } )

    curX = curX + 80
    local c = ssk.colors.rgb2hsl(_O_)
    local c2 = ssk.colors.hsl2rgb( c )
    newRect( group, curX, curY, { size = 80, fill = c2  } )

    curX = curX + 80
    local c = ssk.colors.rgb2hsl(_Y_)
    local c2 = ssk.colors.hsl2rgb( c )
    newRect( group, curX, curY, { size = 80, fill = c2  } )

    curX = curX + 80
    local c = ssk.colors.rgb2hsl(_P_)
    local c2 = ssk.colors.hsl2rgb( c )
    newRect( group, curX, curY, { size = 80, fill = c2  } )

    curX = curX + 80
    local c = ssk.colors.rgb2hsl(_PURPLE_)
    local c2 = ssk.colors.hsl2rgb( c )
    newRect( group, curX, curY, { size = 80, fill = c2  } )

    curX = curX + 80
    local c = ssk.colors.rgb2hsl(_GREY_)
    local c2 = ssk.colors.hsl2rgb( c )
    newRect( group, curX, curY, { size = 80, fill = c2  } )


   -- ==============================================
   -- Row 2 - Test HSL HUE Offset
    -- ==============================================

    -- hueOffset
    curX = startX
    curY = curY + 100
    local c = ssk.colors.rgb2hsl(_R_)
    local c1 = ssk.colors.hueOffset(c, 60 )
    local c2 = ssk.colors.hsl2rgb( c1 )
    newRect( group, curX, curY, { size = 80, fill = c2  } )

    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = _R_  } )

    curX = curX + 80
    local c = ssk.colors.rgb2hsl(_R_)
    local c1 = ssk.colors.hueOffset(c, -60 )
    local c2 = ssk.colors.hsl2rgb( c1 )
    newRect( group, curX, curY, { size = 80, fill = c2  } )

   -- ==============================================
   -- Row 3 - Test HSL Neighbors, Triadic, Split Complementary
    -- ==============================================

    -- hslNeighbors
    curX = startX
    curY = curY + 100
    local c = ssk.colors.rgb2hsl(_R_)
    local c2,c3 = ssk.colors.hslNeighbors( c, 90 )
    c2 = ssk.colors.hsl2rgb( c2 )
    c3 = ssk.colors.hsl2rgb( c3 )   
    newRect( group, curX, curY, { size = 80, fill = c2  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = _R_  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = c3  } )

    -- hslTriadic
    curX = curX + 100
    local c = ssk.colors.rgb2hsl(_R_)
    local c2,c3 = ssk.colors.hslTriadic( c )
    c2 = ssk.colors.hsl2rgb( c2 )
    c3 = ssk.colors.hsl2rgb( c3 )   
    newRect( group, curX, curY, { size = 80, fill = c2  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = _R_  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = c3  } )

    -- hslSplitComplementary
    curX = curX + 100
    local c = ssk.colors.rgb2hsl(_R_)
    local c2,c3 = ssk.colors.hslSplitComplementary( c, 30 )
    c2 = ssk.colors.hsl2rgb( c2 )
    c3 = ssk.colors.hsl2rgb( c3 )   
    newRect( group, curX, curY, { size = 80, fill = c2  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = _R_  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = c3  } )

   -- ==============================================
   -- Row 4 - Test RGB Offset
    -- ==============================================

    -- rgbOffset
    curX = startX
    curY = curY + 100
    local c1 = ssk.colors.rgbOffset( _R_, 60 )
    newRect( group, curX, curY, { size = 80, fill = c1  } )

    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = _R_  } )

    curX = curX + 80
    local c1 = ssk.colors.rgbOffset( _R_, -60 )
    newRect( group, curX, curY, { size = 80, fill = c1  } )

   -- ==============================================
   -- Row 5 - Test RGB Neighbors, Triadic, Split Complementary
    -- ==============================================

    -- hslNeighbors
    curX = startX
    curY = curY + 100
    local c2,c3 = ssk.colors.rgbNeighbors( _R_, 90 )
    newRect( group, curX, curY, { size = 80, fill = c2  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = _R_  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = c3  } )

    -- rgbTriadic
    curX = curX + 100
    local c2,c3 = ssk.colors.rgbTriadic( _R_ )
    newRect( group, curX, curY, { size = 80, fill = c2  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = _R_  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = c3  } )

    -- rgbSplitComplementary
    curX = curX + 100
    local c2,c3 = ssk.colors.rgbSplitComplementary( _R_, 30 )
    newRect( group, curX, curY, { size = 80, fill = c2  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = _R_  } )
    curX = curX + 80
    newRect( group, curX, curY, { size = 80, fill = c3  } )
end

Pastels

Pastels Example


function test.run( group, params )
   group = group or display.currentStage
   params = params or {}

   local startX = left + 100
   local startY = top + 100

   local curX = startX
   local curY = startY

    -- Pastel No Seed Color
    for i = 1, 3 do
        curX = startX   
        for j = 1, 10 do
            newRect( group, curX, curY, { size = 80, fill = ssk.colors.pastelRGB( )  } )
            curX = curX + 80
        end
        curY = curY + 80
    end

    curY = curY + 40

    -- Pastel Random Seed Color
    for i = 1, 3 do
        curX = startX   
        for j = 1, 10 do
            newRect( group, curX, curY, { size = 80, fill = ssk.colors.pastelRGB( randomColor() )  } )
            curX = curX + 80
        end
        curY = curY + 80
    end

end



RoamingGamer Copyright © Roaming Gamer, LLC. 2008-2016; All Rights Reserved