- 29 Eki 2018
- 223
- 0
http://prntscr.com/nj7yki evet bugün ufak bir color picker yapalım sizlerle..
Kod:
f = createForm()
f.Width = 200
f.Height = 400
f.Position = 'poScreenCenter'
--f.Color = '16711680'
f.BorderStyle = 'bsToolWindow'
f.Caption = 'CRDR'
b = createButton(f)
b.Top = 10
b.Left = 10
b.Width = 180
b.Height = 30
b.Caption = 'Color Picker'
p = createPanel(f)
p.Top = b.Top + b.Height + 10
p.Left = 10
p.Width = 180
p.Height = 200
l1 = createLabel(f)
l1.Top = p.Top + p.Height + 10
l1.Left = 10
l1.Width = 180
l1.Height = 30
l1.Caption = 'MS-ACCESS COLOR CODE'
e1 = createEdit(f)
e1.Top = l1.Top + l1.Height + 10
e1.Left = 10
e1.Width = 180
e1.Height = 30
e1.Text = ''
l2 = createLabel(f)
l2.Top = e1.Top + e1.Height + 10
l2.Left = 10
l2.Width = 180
l2.Height = 30
l2.Caption = 'HEX CODE'
e2 = createEdit(f)
e2.Top = l2.Top + l2.Height + 10
e2.Left = 10
e2.Width = 180
e2.Height = 30
e2.Text = ''
l3 = createLabel(f)
l3.Top = e2.Top + e2.Height + 10
l3.Left = 10
l3.Width = 180
l3.Height = 30
l3.Caption = ''
--------------------------------------------------- FUNCTIONS
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
function colorpick()
a = getMainForm()
a.visible = false
local colorPicker = getMainForm().findComponentByName("ColorDialog1")
colorPicker.Execute()
if colorPicker.Execute then
p.Color = colorPicker.Color
c = colorPicker.Color
local r,g,b = c & 0xff, c >> 8 & 0xff, c >> 16 & 0xff
rgbstr = tostring(r)..','..tostring(g)..','..tostring(b)
rgbhex = tostring(RGBToHex(r,g,b))
end
e1.Text = tostring(p.Color) --- print(f.color) -- ms.Access Color
e2.Text = rgbhex
l3.Caption = 'RGB Value : '..rgbstr
end
--local colPick = getMainForm().findComponentByName("ColorDialog1")
--function test()
-- local color = getPixel(getMousePos())
--- print(color)
-- p.Color = color
--end
function exit()
a = getMainForm()
a.visible = true
-- closeCE()
-- return caFree
end
-- MortaL / Javabex / maveracheats
--------------------------------------------------- EVENTS
f.show()
f.onClose = exit
b.onClick = colorpick
--colPick.onMouseDown = test