-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorScreen.lua
More file actions
93 lines (76 loc) · 2.8 KB
/
ColorScreen.lua
File metadata and controls
93 lines (76 loc) · 2.8 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
--Library Acquisition
local rslib = require('rslib')
local json = require('dkjson')
--Background Image
rslib.drawQuickImage("assets.prod.novaquark.com/97299/7a063cc5-f93c-49ff-81be-0387dfa45585.png")
--Layer Creation
ShapeLayer = createLayer()
TextLayer = createLayer()
--Resolution and Mouse Position
rx,ry = getResolution()
rx,ry = rx/100,ry/100
mx,my = getCursor()
mx,my = math.floor(mx),math.floor(my)
--Color Calculation
r=1/255
g=1/255
b=1/255
if red==nil then red=255 end
if green==nil then green=255 end
if blue==nil then blue=255 end
--Defaults
setDefaultTextAlign(TextLayer,AlignH_Center,AlignV_Middle)
setDefaultFillColor(ShapeLayer,Shape_Box,6*r,18*g,21*b,1)
--Fonts
TitleFont=loadFont("Play",10*ry)
MainFont=loadFont("Play",6*ry)
LabelFont=loadFont("Play",3*ry)
--Mouse Locating
--if mx>0*rx and mx<0*rx and my>0*ry and my<0*ry then
mouse=""
--Functions
function DrawColorSliders()
if mx>22*rx and mx<92*rx and my>27*ry and my<33*ry then mouse="red" end
if mx>22*rx and mx<92*rx and my>42*ry and my<48*ry then mouse="green" end
if mx>22*rx and mx<92*rx and my>57*ry and my<63*ry then mouse="blue" end
if mouse=="red" and getCursorDown() then
red=255*(mx-(22*rx))/(70*rx)
if red>254 then red=255 else red=math.floor(red) end
end
if mouse=="green" and getCursorDown() then
green=255*(mx-(22*rx))/(70*rx)
if green>254 then green=255 else green=math.floor(green) end
end
if mouse=="blue" and getCursorDown() then
blue=255*(mx-(22*rx))/(70*rx)
if blue>254 then blue=255 else blue=math.floor(blue) end
end
setNextTextAlign(TextLayer,AlignH_Right,AlignV_Middle)
addText(TextLayer,MainFont,"RED",15*rx,30*ry)
addBox(ShapeLayer,22*rx,27*ry,70*rx,6*ry)
setNextFillColor(ShapeLayer,235*r,235*g,110*b,1)
addBox(ShapeLayer,22*rx,27*ry,(red/255)*70*rx,6*ry)
addText(TextLayer,LabelFont,red,57*rx,35*ry)
setNextTextAlign(TextLayer,AlignH_Right,AlignV_Middle)
addText(TextLayer,MainFont,"GREEN",15*rx,45*ry)
addBox(ShapeLayer,22*rx,42*ry,70*rx,6*ry)
setNextFillColor(ShapeLayer,235*r,235*g,110*b,1)
addBox(ShapeLayer,22*rx,42*ry,(green/255)*70*rx,6*ry)
addText(TextLayer,LabelFont,green,57*rx,50*ry)
setNextTextAlign(TextLayer,AlignH_Right,AlignV_Middle)
addText(TextLayer,MainFont,"BLUE",15*rx,60*ry)
addBox(ShapeLayer,22*rx,57*ry,70*rx,6*ry)
setNextFillColor(ShapeLayer,235*r,235*g,110*b,1)
addBox(ShapeLayer,22*rx,57*ry,(blue/255)*70*rx,6*ry)
addText(TextLayer,LabelFont,blue,57*rx,65*ry)
setNextFillColor(ShapeLayer,red*r,green*g,blue*b,1)
addBoxRounded(ShapeLayer,5*rx,75*ry,90*rx,15*ry,8)
end
function DrawTitle()
addText(TextLayer,TitleFont,"COLOR VISUALIZER",50*rx,10*ry)
end
--Execute
DrawTitle()
DrawColorSliders()
--Animation
requestAnimationFrame(1)