Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Playing With TrackBar And Color

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon Mar 20, 2017 12:14 pm    Post subject: Playing With TrackBar And Color Reply with quote

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...



Capture.JPG
 Description:
RGB Color Blender - Code
 Filesize:  25.71 KB
 Viewed:  6239 Time(s)

Capture.JPG


Back to top
View user's profile Send private message
usernotfound
Expert Cheater
Reputation: 0

Joined: 21 Feb 2016
Posts: 115

PostPosted: Mon Mar 20, 2017 4:59 pm    Post subject: Reply with quote

Neat! Thanks for sharing sir
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon Mar 20, 2017 10:05 pm    Post subject: Reply with quote

usernotfound wrote:
Neat! Thanks for sharing sir


Your welcome.... Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites