Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Mon Mar 20, 2017 12:14 pm Post subject: Playing With TrackBar And Color |
|
|
Hi there,
Just a sample implementing trackbar to get RGB and Hex Color.
Copy script below, paste to CE table lua script and execute.
Code: | function RGBToHex(red, green, blue)
if(red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) then
return nil
end
return string.format("0x%.2X%.2X%.2X", red,green,blue)
end
f = createForm()
f.Width = 300
f.Height = 345
f.Position = 'poScreenCenter'
f.Caption = 'CRDR - RGB COLOR BLENDER'
f.Color = '0x00DFF7FF'
p = createPanel(f)
p.top = 20
p.height = 150
p.width = 250
p.left = math.floor((f.width - p.width) / 2)
p.color = '0x00000000'
t1 = createTrackBar(f)
t1.left = 15
t1.top = p.height + p.top + 20
t1.width = f.width - t1.left - 80
t1.height = 30
t1.Max = 255
t1.Min = 0
t1.position = 0
t1.SelStart = 0
t1.SelEnd = 0
t2 = createTrackBar(f)
t2.left = 15
t2.top = t1.height + t1.top + 10
t2.width = f.width - t2.left - 80
t2.height = 30
t2.Max = 255
t2.Min = 0
t2.position = 0
t2.SelStart = 0
t2.SelEnd = 0
t3 = createTrackBar(f)
t3.left = 15
t3.top = t2.height + t2.top + 10
t3.width = f.width - t3.left - 80
t3.height = 30
t3.Max = 255
t3.Min = 0
t3.position = 0
t3.SelStart = 0
t3.SelEnd = 0
RLabel = createLabel(f)
RLabel.top = t1.top
RLabel.left = t1.left + t1.width + 12
RLabel.caption = 'R : 0'
RLabel.font.color = '0x001717FF'
RLabel.font.style = 'fsBold'
GLabel = createLabel(f)
GLabel.top = t2.top
GLabel.left = t2.left + t2.width + 12
GLabel.caption = 'G : 0'
GLabel.font.color = '0x00009300'
GLabel.font.style = 'fsBold'
BLabel = createLabel(f)
BLabel.top = t3.top
BLabel.left = t3.left + t3.width + 12
BLabel.caption = 'B : 0'
BLabel.font.color = '0x00FF2020'
BLabel.font.style = 'fsBold'
HxLabel = createLabel(f)
HxLabel.top = t3.top + t3.height + 15
HxLabel.left = t3.left
HxLabel.caption = ' Current Hex Color Code : '
Hx1Label = createLabel(f)
Hx1Label.top = t3.top + t3.height + 7
Hx1Label.left = HxLabel.left + HxLabel.width
Hx1Label.font.size = 14
Hx1Label.font.style = 'fsBold'
Hx1Label.caption = ' '
function exit()
closeCE()
return caFree
end
f.show()
R = 0
G = 0
B = 0
col = nil
function rtbChange(sender)
R = t1.position
G = t2.position
B = t3.position
RLabel.Caption = 'R : '..tostring(t1.position)
col = RGBToHex(R,G,B)
p.color = col
Hx1Label.caption = tostring(col)
end
function gtbChange(sender)
R = t1.position
G = t2.position
B = t3.position
GLabel.Caption = 'G : '..tostring(t2.position)
col = RGBToHex(R,G,B)
p.color = col
Hx1Label.caption = tostring(col)
end
function btbChange(sender)
R = t1.position
G = t2.position
B = t3.position
BLabel.Caption = 'B : '..tostring(t3.position)
col = RGBToHex(R,G,B)
p.color = col
Hx1Label.caption = tostring(col)
end
t1.onChange = rtbChange
t2.onChange = gtbChange
t3.onChange = btbChange
f.onClose = exit |
Have fun and regards...
Description: |
|
Filesize: |
25.71 KB |
Viewed: |
6275 Time(s) |
|
|
|