Skip to content

Instantly share code, notes, and snippets.

@jstrahan
Created March 9, 2014 18:03
Show Gist options
  • Save jstrahan/9451714 to your computer and use it in GitHub Desktop.
Save jstrahan/9451714 to your computer and use it in GitHub Desktop.
rgb
-----------------------------------------------------------------
-- copyright © 2014 Jeff Strahan --
-- Permission is granted to use this code --
-- in any of you own projects free of charge --
-- For more modules, templates, tutorials, and snippets --
-- visit http://www.j-strahan.com --
-----------------------------------------------------------------
-- --
-- _rgb.lua is a module used to set object --
-- colors by using color names. --
-- CURRENT COLOR COUNT 164 --
-----------------------------------------------------------------
-- color values taken from --
-- http://www.avatar.se/molscript/doc/colour_names.html --
-- --
-----------------------------------------------------------------
local M
M = { aliceblue = { 0.941176, 0.972549, 1 },
antiquewhite = { 0.980392, 0.921569, 0.843137 },
aquamarine = { 0.498039, 1, 0.831373 },
azure = { 0.941176, 1, 1 },
beige = { 0.960784, 0.960784, 0.862745 },
bisque = { 1, 0.894118, 0.768627 },
black = { 0, 0, 0 },
blanchedalmond = { 1, 0.921569, 0.803922 },
blue = { 0, 0, 1 },
blueviolet = { 0.541176, 0.168627, 0.886275 },
brown = { 0.647059, 0.164706, 0.164706 },
burlywood = { 0.870588, 0.721569, 0.529412 },
cadetblue = { 0.372549, 0.619608, 0.627451 },
chartreuse = { 0.498039, 1, 0 },
chocolate = { 0.823529, 0.411765, 0.117647 },
coral = { 1, 0.498039, 0.313725 },
cornflowerblue = { 0.392157, 0.584314, 0.929412 },
cornsilk = { 1, 0.972549, 0.862745 },
crimson = { 0.862745, 0.0784314, 0.235294 },
cyan = { 0, 1, 1 },
darkblue = { 0, 0, 0.545098 },
darkcyan = { 0, 0.545098, 0.545098 },
darkgoldenrod = { 0.721569, 0.52549, 0.0431373 },
darkgray = { 0.662745, 0.662745, 0.662745 },
darkgreen = { 0, 0.392157, 0 },
darkgrey = { 0.662745, 0.662745, 0.662745 },
darkkhaki = { 0.741176, 0.717647, 0.419608 },
darkmagenta = { 0.545098, 0, 0.545098 },
darkolivegreen = { 0.333333, 0.419608, 0.184314 },
darkorange = { 1, 0.54902, 0 },
darkorchid = { 0.6, 0.196078, 0.8 },
darkred = { 0.545098, 0, 0 },
darksalmon = { 0.913725, 0.588235, 0.478431 },
darkseagreen = { 0.560784, 0.737255, 0.560784 },
darkslateblue = { 0.282353, 0.239216, 0.545098 },
darkslategray = { 0.184314, 0.309804, 0.309804 },
darkslategrey = { 0.184314, 0.309804, 0.309804 },
darkturquoise = { 0, 0.807843, 0.819608 },
darkviolet = { 0.580392, 0, 0.827451 },
deeppink = { 1, 0.0784314, 0.576471 },
deepskyblue = { 0, 0.74902, 1 },
dimgray = { 0.411765, 0.411765, 0.411765 },
dimgrey = { 0.411765, 0.411765, 0.411765 },
dodgerblue = { 0.117647, 0.564706, 1 },
firebrick = { 0.698039, 0.133333, 0.133333 },
floralwhite = { 1, 0.980392, 0.941176 },
forestgreen = { 0.133333, 0.545098, 0.133333 },
gainsboro = { 0.862745, 0.862745, 0.862745 },
ghostwhite = { 0.972549, 0.972549, 1 },
gold = { 1, 0.843137, 0 },
goldenrod = { 0.854902, 0.647059, 0.12549 },
gray = { 0.745098, 0.745098, 0.745098 },
green = { 0, 1, 0 },
greenyellow = { 0.678431, 1, 0.184314 },
grey = { 0.745098, 0.745098, 0.745098 },
honeydew = { 0.941176, 1, 0.941176 },
hotpink = { 1, 0.411765, 0.705882 },
indianred = { 0.803922, 0.360784, 0.360784 },
indigo = { 0.294118, 0, 0.509804 },
ivory = { 1, 1, 0.941176 },
khaki = { 0.941176, 0.901961, 0.54902 },
lavender = { 0.901961, 0.901961, 0.980392 },
lavenderblush = { 1, 0.941176, 0.960784 },
lawngreen = { 0.486275, 0.988235, 0 },
lemonchiffon = { 1, 0.980392, 0.803922 },
lightblue = { 0.678431, 0.847059, 0.901961 },
lightcoral = { 0.941176, 0.501961, 0.501961 },
lightcyan = { 0.878431, 1, 1 },
lightgoldenrod = { 0.933333, 0.866667, 0.509804 },
lightgoldenrodyellow = { 0.980392, 0.980392, 0.823529 },
lightgray = { 0.827451, 0.827451, 0.827451 },
lightgreen = { 0.564706, 0.933333, 0.564706 },
lightgrey = { 0.827451, 0.827451, 0.827451 },
lightpink = { 1, 0.713725, 0.756863 },
lightsalmon = { 1, 0.627451, 0.478431 },
lightseagreen = { 0.12549, 0.698039, 0.666667 },
lightskyblue = { 0.529412, 0.807843, 0.980392 },
lightslateblue = { 0.517647, 0.439216, 1 },
lightslategray = { 0.466667, 0.533333, 0.6 },
lightslategrey = { 0.466667, 0.533333, 0.6 },
lightsteelblue = { 0.690196, 0.768627, 0.870588 },
lightyellow = { 1, 1, 0.878431 },
limegreen = { 0.196078, 0.803922, 0.196078 },
linen = { 0.980392, 0.941176, 0.901961 },
magenta = { 1, 0, 1 },
maroon = { 0.690196, 0.188235, 0.376471 },
mediumaquamarine = { 0.4, 0.803922, 0.666667 },
mediumblue = { 0, 0, 0.803922 },
mediumorchid = { 0.729412, 0.333333, 0.827451 },
mediumpurple = { 0.576471, 0.439216, 0.858824 },
mediumseagreen = { 0.235294, 0.701961, 0.443137 },
mediumslateblue = { 0.482353, 0.407843, 0.933333 },
mediumspringgreen = { 0, 0.980392, 0.603922 },
mediumturquoise = { 0.282353, 0.819608, 0.8 },
mediumvioletred = { 0.780392, 0.0823529, 0.521569 },
midnightblue = { 0.0980392, 0.0980392, 0.439216 },
mintcream = { 0.960784, 1, 0.980392 },
mistyrose = { 1, 0.894118, 0.882353 },
moccasin = { 1, 0.894118, 0.709804 },
navajowhite = { 1, 0.870588, 0.678431 },
navy = { 0, 0, 0.501961 },
navyblue = { 0, 0, 0.501961 },
oldlace = { 0.992157, 0.960784, 0.901961 },
olivedrab = { 0.419608, 0.556863, 0.137255 },
orange = { 1, 0.647059, 0 },
orangered = { 1, 0.270588, 0 },
orchid = { 0.854902, 0.439216, 0.839216 },
palegoldenrod = { 0.933333, 0.909804, 0.666667 },
palegreen = { 0.596078, 0.984314, 0.596078 },
paleturquoise = { 0.686275, 0.933333, 0.933333 },
palevioletred = { 0.858824, 0.439216, 0.576471 },
papayawhip = { 1, 0.937255, 0.835294 },
peachpuff = { 1, 0.854902, 0.72549 },
peru = { 0.803922, 0.521569, 0.247059 },
pink = { 1, 0.752941, 0.796078 },
plum = { 0.866667, 0.627451, 0.866667 },
powderblue = { 0.690196, 0.878431, 0.901961 },
purple = { 0.627451, 0.12549, 0.941176 },
red = { 1, 0, 0 },
rosybrown = { 0.737255, 0.560784, 0.560784 },
royalblue = { 0.254902, 0.411765, 0.882353 },
saddlebrown = { 0.545098, 0.270588, 0.0745098 },
salmon = { 0.980392, 0.501961, 0.447059 },
sandybrown = { 0.956863, 0.643137, 0.376471 },
seagreen = { 0.180392, 0.545098, 0.341176 },
seashell = { 1, 0.960784, 0.933333 },
sgibeet = { 0.556863, 0.219608, 0.556863 },
sgibrightgray = { 0.772549, 0.756863, 0.666667 },
sgibrightgrey = { 0.772549, 0.756863, 0.666667 },
sgichartreuse = { 0.443137, 0.776471, 0.443137 },
sgidarkgray = { 0.333333, 0.333333, 0.333333 },
sgidarkgrey = { 0.333333, 0.333333, 0.333333 },
sgilightblue = { 0.490196, 0.619608, 0.752941 },
sgilightgray = { 0.666667, 0.666667, 0.666667 },
sgilightgrey = { 0.666667, 0.666667, 0.666667 },
sgimediumgray = { 0.517647, 0.517647, 0.517647 },
sgimediumgrey = { 0.517647, 0.517647, 0.517647 },
sgiolivedrab = { 0.556863, 0.556863, 0.219608 },
sgisalmon = { 0.776471, 0.443137, 0.443137 },
sgislateblue = { 0.443137, 0.443137, 0.776471 },
sgiteal = { 0.219608, 0.556863, 0.556863 },
sgiverydarkgray = { 0.156863, 0.156863, 0.156863 },
sgiverydarkgrey = { 0.156863, 0.156863, 0.156863 },
sgiverylightgray = { 0.839216, 0.839216, 0.839216 },
sgiverylightgrey = { 0.839216, 0.839216, 0.839216 },
sienna = { 0.627451, 0.321569, 0.176471 },
skyblue = { 0.529412, 0.807843, 0.921569 },
slateblue = { 0.415686, 0.352941, 0.803922 },
slategray = { 0.439216, 0.501961, 0.564706 },
slategrey = { 0.439216, 0.501961, 0.564706 },
snow = { 1, 0.980392, 0.980392 },
springgreen = { 0, 1, 0.498039 },
steelblue = { 0.27451, 0.509804, 0.705882 },
tan = { 0.823529, 0.705882, 0.54902 },
thistle = { 0.847059, 0.74902, 0.847059 },
tomato = { 1, 0.388235, 0.278431 },
turquoise = { 0.25098, 0.878431, 0.815686 },
violet = { 0.933333, 0.509804, 0.933333 },
violetred = { 0.815686, 0.12549, 0.564706 },
wheat = { 0.960784, 0.870588, 0.701961 },
white = { 1, 1, 1 },
whitesmoke = { 0.960784, 0.960784, 0.960784 },
yellow = { 1, 1, 0 },
yellowgreen = { 0.603922, 0.803922, 0.196078 }
}
function M.color( arg )
local arg = arg or "white"
if M[arg] then
return M[arg][1], M[arg][2], M[arg][3]
else
return 1, 1, 1
end
end
return M
local rgb = require '_rgb'
local cir1 = display.newCircle( 40, 240, 35 )
local cir2 = display.newCircle( 120, 240, 35 )
local cir3 = display.newCircle( 200, 240, 35 )
local cir4 = display.newCircle( 280, 240, 35 )
cir1:setFillColor( rgb.color("blue") )
cir2.fill = rgb.red
cir3:setFillColor( { type="gradient", color1=rgb.white, color2=rgb.yellow, direction="down" } )
cir4.fill = { type="gradient", color1=rgb.yellow, color2=rgb.white, direction="down" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment