Updated some items, moved deprecated or not-working scripts into its own folder, may eventually get rid of them altogether.pull/4/head
parent
ba3a13ab2c
commit
1becd36589
@ -1,308 +1,308 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!DOCTYPE muclient>
|
<!DOCTYPE muclient>
|
||||||
<!-- Saved on Saturday, May 12, 2018, 12:51 AM -->
|
<!-- Saved on Saturday, May 12, 2018, 12:51 AM -->
|
||||||
<!-- MuClient version 5.06-pre -->
|
<!-- MuClient version 5.06-pre -->
|
||||||
|
|
||||||
<!-- Plugin "Contrast_Picker" generated by Plugin Wizard -->
|
<!-- Plugin "Contrast_Picker" generated by Plugin Wizard -->
|
||||||
|
|
||||||
<muclient>
|
<muclient>
|
||||||
<plugin
|
<plugin
|
||||||
name="Contrast_Picker"
|
name="Contrast_Picker"
|
||||||
author="Crowley"
|
author="Crowley"
|
||||||
id="977138a7afb5ab493795edb7"
|
id="977138a7afb5ab493795edb7"
|
||||||
language="Lua"
|
language="Lua"
|
||||||
purpose="Checks contrast ratios to pick better contrasting colors."
|
purpose="Checks contrast ratios to pick better contrasting colors."
|
||||||
save_state="y"
|
save_state="y"
|
||||||
date_written="2018-05-12 00:48:25"
|
date_written="2018-05-12 00:48:25"
|
||||||
requires="4.80"
|
requires="4.80"
|
||||||
version="1.0"
|
version="1.0"
|
||||||
>
|
>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
<!-- Aliases -->
|
<!-- Aliases -->
|
||||||
|
|
||||||
<aliases>
|
<aliases>
|
||||||
<alias
|
<alias
|
||||||
script="onCommand"
|
script="onCommand"
|
||||||
match="^contrast (.*?)(?:\s(.*?))?(?:\s(.*?))?$"
|
match="^contrast (.*?)(?:\s(.*?))?(?:\s(.*?))?$"
|
||||||
enabled="y"
|
enabled="y"
|
||||||
group="ContrastChecker"
|
group="ContrastChecker"
|
||||||
regexp="y"
|
regexp="y"
|
||||||
send_to="12"
|
send_to="12"
|
||||||
sequence="100"
|
sequence="100"
|
||||||
>
|
>
|
||||||
</alias>
|
</alias>
|
||||||
</aliases>
|
</aliases>
|
||||||
|
|
||||||
<!-- Script -->
|
<!-- Script -->
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
color_table = {
|
color_table = {
|
||||||
|
|
||||||
"pink",
|
"pink",
|
||||||
"lightpink",
|
"lightpink",
|
||||||
"hotpink",
|
"hotpink",
|
||||||
"deeppink",
|
"deeppink",
|
||||||
"palevioletred",
|
"palevioletred",
|
||||||
"mediumvioletred",
|
"mediumvioletred",
|
||||||
"lightsalmon",
|
"lightsalmon",
|
||||||
"salmon",
|
"salmon",
|
||||||
"darksalmon",
|
"darksalmon",
|
||||||
"lightcoral",
|
"lightcoral",
|
||||||
"indianred",
|
"indianred",
|
||||||
"crimson",
|
"crimson",
|
||||||
"firebrick",
|
"firebrick",
|
||||||
"darkred",
|
"darkred",
|
||||||
"red",
|
"red",
|
||||||
"orangered",
|
"orangered",
|
||||||
"tomato",
|
"tomato",
|
||||||
"coral",
|
"coral",
|
||||||
"darkorange",
|
"darkorange",
|
||||||
"orange",
|
"orange",
|
||||||
"yellow",
|
"yellow",
|
||||||
"lightyellow",
|
"lightyellow",
|
||||||
"lemonchiffon",
|
"lemonchiffon",
|
||||||
"lightgoldenrodyellow",
|
"lightgoldenrodyellow",
|
||||||
"papayawhip",
|
"papayawhip",
|
||||||
"moccasin",
|
"moccasin",
|
||||||
"peachpuff",
|
"peachpuff",
|
||||||
"palegoldenrod",
|
"palegoldenrod",
|
||||||
"khaki",
|
"khaki",
|
||||||
"darkkhaki",
|
"darkkhaki",
|
||||||
"gold",
|
"gold",
|
||||||
"cornsilk",
|
"cornsilk",
|
||||||
"blanchedalmond",
|
"blanchedalmond",
|
||||||
"bisque",
|
"bisque",
|
||||||
"navajowhite",
|
"navajowhite",
|
||||||
"wheat",
|
"wheat",
|
||||||
"burlywood",
|
"burlywood",
|
||||||
"tan",
|
"tan",
|
||||||
"rosybrown",
|
"rosybrown",
|
||||||
"sandybrown",
|
"sandybrown",
|
||||||
"goldenrod",
|
"goldenrod",
|
||||||
"darkgoldenrod",
|
"darkgoldenrod",
|
||||||
"peru",
|
"peru",
|
||||||
"chocolate",
|
"chocolate",
|
||||||
"saddlebrown",
|
"saddlebrown",
|
||||||
"sienna",
|
"sienna",
|
||||||
"brown",
|
"brown",
|
||||||
"maroon",
|
"maroon",
|
||||||
"lavender",
|
"lavender",
|
||||||
"thistle",
|
"thistle",
|
||||||
"plum",
|
"plum",
|
||||||
"violet",
|
"violet",
|
||||||
"orchid",
|
"orchid",
|
||||||
"fuchsia",
|
"fuchsia",
|
||||||
"magenta",
|
"magenta",
|
||||||
"mediumorchid",
|
"mediumorchid",
|
||||||
"mediumpurple",
|
"mediumpurple",
|
||||||
"blueviolet",
|
"blueviolet",
|
||||||
"darkviolet",
|
"darkviolet",
|
||||||
"darkorchid",
|
"darkorchid",
|
||||||
"darkmagenta",
|
"darkmagenta",
|
||||||
"purple",
|
"purple",
|
||||||
"indigo",
|
"indigo",
|
||||||
"slateblue",
|
"slateblue",
|
||||||
"darkslateblue",
|
"darkslateblue",
|
||||||
"mediumslateblue",
|
"mediumslateblue",
|
||||||
"greenyellow",
|
"greenyellow",
|
||||||
"chartreuse",
|
"chartreuse",
|
||||||
"lawngreen",
|
"lawngreen",
|
||||||
"lime",
|
"lime",
|
||||||
"limegreen",
|
"limegreen",
|
||||||
"palegreen",
|
"palegreen",
|
||||||
"lightgreen",
|
"lightgreen",
|
||||||
"mediumspringgreen",
|
"mediumspringgreen",
|
||||||
"springgreen",
|
"springgreen",
|
||||||
"mediumseagreen",
|
"mediumseagreen",
|
||||||
"seagreen",
|
"seagreen",
|
||||||
"forestgreen",
|
"forestgreen",
|
||||||
"green",
|
"green",
|
||||||
"darkgreen",
|
"darkgreen",
|
||||||
"yellowgreen",
|
"yellowgreen",
|
||||||
"olivedrab",
|
"olivedrab",
|
||||||
"olive",
|
"olive",
|
||||||
"darkolivegreen",
|
"darkolivegreen",
|
||||||
"mediumaquamarine",
|
"mediumaquamarine",
|
||||||
"darkseagreen",
|
"darkseagreen",
|
||||||
"lightseagreen",
|
"lightseagreen",
|
||||||
"darkcyan",
|
"darkcyan",
|
||||||
"teal",
|
"teal",
|
||||||
"aqua",
|
"aqua",
|
||||||
"cyan",
|
"cyan",
|
||||||
"lightcyan",
|
"lightcyan",
|
||||||
"paleturquoise",
|
"paleturquoise",
|
||||||
"aquamarine",
|
"aquamarine",
|
||||||
"turquoise",
|
"turquoise",
|
||||||
"mediumturquoise",
|
"mediumturquoise",
|
||||||
"darkturquoise",
|
"darkturquoise",
|
||||||
"cadetblue",
|
"cadetblue",
|
||||||
"steelblue",
|
"steelblue",
|
||||||
"lightsteelblue",
|
"lightsteelblue",
|
||||||
"powderblue",
|
"powderblue",
|
||||||
"lightblue",
|
"lightblue",
|
||||||
"skyblue",
|
"skyblue",
|
||||||
"lightskyblue",
|
"lightskyblue",
|
||||||
"deepskyblue",
|
"deepskyblue",
|
||||||
"dodgerblue",
|
"dodgerblue",
|
||||||
"cornflowerblue",
|
"cornflowerblue",
|
||||||
"mediumslateblue",
|
"mediumslateblue",
|
||||||
"royalblue",
|
"royalblue",
|
||||||
"blue",
|
"blue",
|
||||||
"mediumblue",
|
"mediumblue",
|
||||||
"darkblue",
|
"darkblue",
|
||||||
"navy",
|
"navy",
|
||||||
"midnightblue",
|
"midnightblue",
|
||||||
"white",
|
"white",
|
||||||
"snow",
|
"snow",
|
||||||
"honeydew",
|
"honeydew",
|
||||||
"mintcream",
|
"mintcream",
|
||||||
"azure",
|
"azure",
|
||||||
"aliceblue",
|
"aliceblue",
|
||||||
"ghostwhite",
|
"ghostwhite",
|
||||||
"whitesmoke",
|
"whitesmoke",
|
||||||
"seashell",
|
"seashell",
|
||||||
"beige",
|
"beige",
|
||||||
"oldlace",
|
"oldlace",
|
||||||
"floralwhite",
|
"floralwhite",
|
||||||
"ivory",
|
"ivory",
|
||||||
"antiquewhite",
|
"antiquewhite",
|
||||||
"linen",
|
"linen",
|
||||||
"lavenderblush",
|
"lavenderblush",
|
||||||
"mistyrose",
|
"mistyrose",
|
||||||
"gainsboro",
|
"gainsboro",
|
||||||
"lightgrey",
|
"lightgrey",
|
||||||
"silver",
|
"silver",
|
||||||
"darkgray",
|
"darkgray",
|
||||||
"gray",
|
"gray",
|
||||||
"dimgray",
|
"dimgray",
|
||||||
"lightslategray",
|
"lightslategray",
|
||||||
"slategray",
|
"slategray",
|
||||||
"darkslategray",
|
"darkslategray",
|
||||||
"black"
|
"black"
|
||||||
}
|
}
|
||||||
|
|
||||||
function lumRGB(s)
|
function lumRGB(s)
|
||||||
local red, green, blue, l = 0, 0, 0, 0
|
local red, green, blue, l = 0, 0, 0, 0
|
||||||
|
|
||||||
red = s%256
|
red = s%256
|
||||||
s = math.floor(s/256)
|
s = math.floor(s/256)
|
||||||
green = s%256
|
green = s%256
|
||||||
s = math.floor(s/256)
|
s = math.floor(s/256)
|
||||||
blue = s%256
|
blue = s%256
|
||||||
|
|
||||||
red = lumForm(red)
|
red = lumForm(red)
|
||||||
green = lumForm(green)
|
green = lumForm(green)
|
||||||
blue = lumForm(blue)
|
blue = lumForm(blue)
|
||||||
|
|
||||||
l = (0.2126*red) + (0.7152*green) + (0.0722*blue)
|
l = (0.2126*red) + (0.7152*green) + (0.0722*blue)
|
||||||
|
|
||||||
return l
|
return l
|
||||||
end
|
end
|
||||||
|
|
||||||
function lumForm(s)
|
function lumForm(s)
|
||||||
local s = tonumber(s)
|
local s = tonumber(s)
|
||||||
s = s/255
|
s = s/255
|
||||||
|
|
||||||
if s <= 0.03928 then
|
if s <= 0.03928 then
|
||||||
s = s/12.92
|
s = s/12.92
|
||||||
else
|
else
|
||||||
s = ((s+0.055)/1.055)^2.4
|
s = ((s+0.055)/1.055)^2.4
|
||||||
end
|
end
|
||||||
|
|
||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
function contrastCheck(a, b)
|
function contrastCheck(a, b)
|
||||||
local a, b, s = tonumber(a), tonumber(b), 0
|
local a, b, s = tonumber(a), tonumber(b), 0
|
||||||
|
|
||||||
if a > b then
|
if a > b then
|
||||||
s = (a + 0.05)/(b + 0.05)
|
s = (a + 0.05)/(b + 0.05)
|
||||||
else
|
else
|
||||||
s = (b + 0.05)/(a + 0.05)
|
s = (b + 0.05)/(a + 0.05)
|
||||||
end
|
end
|
||||||
|
|
||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
function checkColor(s, b, e)
|
function checkColor(s, b, e)
|
||||||
local max = 0
|
local max = 0
|
||||||
local b, e = tonumber(b), tonumber(e)
|
local b, e = tonumber(b), tonumber(e)
|
||||||
local ctable = {}
|
local ctable = {}
|
||||||
local sortcolors = {}
|
local sortcolors = {}
|
||||||
local l = lumRGB(ColourNameToRGB(s))
|
local l = lumRGB(ColourNameToRGB(s))
|
||||||
|
|
||||||
for _,v in ipairs(color_table) do
|
for _,v in ipairs(color_table) do
|
||||||
local ctrast = contrastCheck(l, lumRGB(ColourNameToRGB(v)))
|
local ctrast = contrastCheck(l, lumRGB(ColourNameToRGB(v)))
|
||||||
|
|
||||||
if ctrast > 1 then
|
if ctrast > 1 then
|
||||||
table.insert(ctable, {color = v, contrast = ctrast})
|
table.insert(ctable, {color = v, contrast = ctrast})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.sort(ctable, function(a,b) return a.contrast > b.contrast end)
|
table.sort(ctable, function(a,b) return a.contrast > b.contrast end)
|
||||||
|
|
||||||
if b == "" or b == nil then b = 1 end
|
if b == "" or b == nil then b = 1 end
|
||||||
if e == "" or e == nil then e = 20 end
|
if e == "" or e == nil then e = 20 end
|
||||||
if e > #ctable then
|
if e > #ctable then
|
||||||
if b > e then
|
if b > e then
|
||||||
b = 1
|
b = 1
|
||||||
e = #ctable
|
e = #ctable
|
||||||
else
|
else
|
||||||
e = #ctable
|
e = #ctable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if b > e then
|
if b > e then
|
||||||
if e < 21 then
|
if e < 21 then
|
||||||
b = 1
|
b = 1
|
||||||
else
|
else
|
||||||
b = e - 20
|
b = e - 20
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Note("Showing best matches for " .. s .. ":")
|
Note("Showing best matches for " .. s .. ":")
|
||||||
if #ctable > 0 then
|
if #ctable > 0 then
|
||||||
for i = b,e do
|
for i = b,e do
|
||||||
ColourNote(s, ctable[i].color, i .. " - Sample text using " .. s .. " on " .. ctable[i].color .. " background. (" .. string.format("%.2f", ctable[i].contrast) .. ":1)")
|
ColourNote(s, ctable[i].color, i .. " - Sample text using " .. s .. " on " .. ctable[i].color .. " background. (" .. string.format("%.2f", ctable[i].contrast) .. ":1)")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ColourNote(s, "", "Sorry, " .. s .. " does not pair well with any background, except maybe black.")
|
ColourNote(s, "", "Sorry, " .. s .. " does not pair well with any background, except maybe black.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function onCommand(name, line, arg)
|
function onCommand(name, line, arg)
|
||||||
if arg[1]:upper() == "HELP" then
|
if arg[1]:upper() == "HELP" then
|
||||||
onHelp()
|
onHelp()
|
||||||
else
|
else
|
||||||
checkColor(arg[1], arg[2], arg[3])
|
checkColor(arg[1], arg[2], arg[3])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function onHelp()
|
function onHelp()
|
||||||
Note("Contrast Generator Help:")
|
Note("Contrast Generator Help:")
|
||||||
Note("contrast help - Brings up this help file")
|
Note("contrast help - Brings up this help file")
|
||||||
Note("contrast <color> - Returns the top 20 contrast ratios")
|
Note("contrast <color> - Returns the top 20 contrast ratios")
|
||||||
Note("contrast <color> <num1> <num2> - Returns contrast ratios ranked num1 through num2")
|
Note("contrast <color> <num1> <num2> - Returns contrast ratios ranked num1 through num2")
|
||||||
Note("*<color> must be html color name (e.g. aliceblue, yellow, darkgreen, etc.)")
|
Note("*<color> must be html color name (e.g. aliceblue, yellow, darkgreen, etc.)")
|
||||||
Note("")
|
Note("")
|
||||||
Note("This plugin helps you decide the best contrasting colors by comparing")
|
Note("This plugin helps you decide the best contrasting colors by comparing")
|
||||||
Note("the luminance values and returning a ratio. Ratios are ranked from 1:1")
|
Note("the luminance values and returning a ratio. Ratios are ranked from 1:1")
|
||||||
Note("to 21:1. The higher the ratio, the better the contrast, thus the better")
|
Note("to 21:1. The higher the ratio, the better the contrast, thus the better")
|
||||||
Note("your ability to read the text will be.")
|
Note("your ability to read the text will be.")
|
||||||
end
|
end
|
||||||
|
|
||||||
function OnPluginInstall()
|
function OnPluginInstall()
|
||||||
if not GetVariable("already_sent") then
|
if not GetVariable("already_sent") then
|
||||||
onHelp()
|
onHelp()
|
||||||
SetVariable("already_sent", "true")
|
SetVariable("already_sent", "true")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
]]>
|
]]>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
</muclient>
|
</muclient>
|
Loading…
Reference in new issue