-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathshade-generator.lua
48 lines (40 loc) · 1.17 KB
/
shade-generator.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- Aseprite Script to open dialog to create related shades
-- Written by aquova, 2018
-- https://github.com/aquova/aseprite-scripts
-- Open dialog, ask user for a color
function userInput()
local dlg = Dialog()
-- Creates a starting color of black
local defaultColor = Color{r=0, g=0, b=0, a=255}
dlg:color{ id="color1", label="Choose a color", color=defaultColor }
dlg:button{ id="ok", text="OK" }
dlg:button{ id="cancel", text="Cancel" }
dlg:show()
return dlg.data
end
function generateColors(color)
local colors = {}
for light=1,0,-0.1 do
local newCol = Color{h=color.hslHue, s=color.hslSaturation, l=light}
table.insert(colors, newCol)
end
return colors
end
function showOutput(color)
local dlg = Dialog()
local colors = generateColors(color)
for i=1,#colors do
dlg:newrow()
dlg:color{color=colors[i]}
end
dlg:button{ id="ok", text="OK" }
dlg:show()
end
-- Run script
do
local color = userInput()
if color.ok then
local userColor = Color{r=color.color1.red, g=color.color1.green, b=color.color1.blue, a=color.color1.alpha}
showOutput(userColor)
end
end