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 


About Canvas

 
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: 1668

PostPosted: Thu Mar 21, 2019 3:16 am    Post subject: About Canvas Reply with quote

How to use :

1. gradientFill(x1,y1,x2,y2, '0xffffff', '0x000000', 1.) ?
2. createRegion()
3. addRectangle(x1, y1, x2, y2)
4. addPolygon(tablewithcoordinates)

If there some examples would be helpful. Thank you

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25820
Location: The netherlands

PostPosted: Thu Mar 21, 2019 6:32 am    Post subject: Reply with quote

regions aren't really canvas related but here's an example:
Code:

f=createForm()

pb=createPaintBox(f)
pb.Width=100
pb.Height=100
pb.OnPaint=function(s)
  s.Canvas.gradientFill(0,0,s.width,s.height,0xff0000,0x00ffff,1)
end

pb2=createPaintBox(f)
pb2.Width=100
pb2.Height=100
pb2.Left=101
pb2.OnPaint=function(s)
  s.Canvas.gradientFill(0,0,s.width,s.height,0x0000ff,0xffff00,2)
end

f.AutoSize=true
f.Position='poScreenCenter'
f.BorderStyle="bsSizeable"

r=createRegion()
r.addRectangle(0,0,20,20)
r.addRectangle(0,20,100,200)
r.addPolygon({{100,50},{125,25},{150,50},{125,75}})
r.addRectangle(f.Width-30,20,f.Width+20,200)
f.setShape(r)


_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Mar 21, 2019 6:42 am    Post subject: Reply with quote

haven't done it myself but
https://www.google.com/search?q=site%3Acheatengine.org+gradientFill - https://www.cheatengine.org/forum/viewtopic.php?p=5568776&sid=bc1fe088d54d130c5381a0d4c62ca701

https://www.google.com/search?q=site%3Acheatengine.org+addPolygon - https://cheatengine.org/help/Scriptengine.htm while not a full example it does still show an example of how to pass arguments
Code:

  addRectangle(x1, y1, x2, y2): Adds a rectangle to the region
  addPolygon(tablewithcoordinates): Adds an array of 2D locations. (example : {{0,0},{100,100}, {0,100}} for a triangle )

presumably those will add shapes to the region which will be drawn

random crap I made
Code:
f = createForm()
i = createImage(f)
c = i.Canvas

c.clear()
c.Brush.Color=0x00FFFF
c.fillRect(0,0,c.Width,c.Height)

local vert = 0
local horz = 1
c.gradientFill(0,0,c.Width,c.Height/2,0xA0, 0x0, horz)

r = createRegion()
r.addPolygon({{0,0},{f.Width/2,f.Height/2}, {0,f.Height/2}})
-- didn't see anything else using region so /shrug
f.setShape(r)

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Thu Mar 21, 2019 7:39 am    Post subject: Reply with quote

Thanks, DB and FreeER also. Now I understand how to use CE Region.
Anyhow, I am already read ScriptEngine/Cheat Engine help file from provided links. Just have some curious because of no samples there.

You both, Very helpful sample.

Another crap :

Code:
function DrawLineWTimer()
 r = math.random(x0)
 y = y0-r  u = u + 1
 pen.Color = math.random(0xffffff)
 x = x0 + math.floor(r * math.sin(u * math.pi/180))
 y = y0 - math.floor(r * math.cos(u * math.pi/180))
 canvas.line(x0, y0, x, y)
 if(u > 360) then u = 0 end
end

if(form == nil) then
 form = createForm(true)
 form.width = 800
 form.height = 800
 form.centerScreen()
 form.caption = 'CRDR-Test Animated Lines'
 canvas = form.getCanvas()
 pen = canvas.Pen
 x0 = form.ClientWidth / 2
 y0 = form.ClientHeight / 2
 u = 0
 r = y0 - 20
 x = x0
 t = createTimer(form, true)
 t.Interval = 10
 t.OnTimer = DrawLineWTimer
end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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