 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Mon Feb 22, 2021 7:37 am Post subject: Can I draw arrows on the canvas |
|
|
I can draw a straight line. I want to draw it as an arrow. What should I do
Code: | if f then f.Destroy() end
f=createForm()
--f.BorderStyle='bsNone'
f.Color=0x00ffff
f.setSize(300,300)
f.Position='poDesktopCenter'
f.FormStyle='fsSystemStayOnTop'
f.tag=0
p=createLabel(f)
p.Align='alBottom'
p.font.size=15
p.caption=string.format('OnPaint: X:%s Y:%s',x,y)
f.setLayeredAttributes(0xB4,230,3,3)
local xx , yy = 0 , 0
function OnPaint(sender,xx,yy,x,y)
sender.repaint()
sender.Canvas.Pen.Color=0x00
sender.Canvas.Pen.Width=2
sender.Canvas.Brush.Color=0xff
sender.Canvas.Brush.Style=1
--sender.Canvas.ellipse(xx,yy,x,y)
--sender.Canvas.roundRect(xx,yy,x,y,16,16)
sender.Canvas.line(xx,yy,x,y)
sender.Canvas.textOut(250,50,'↑↑')
sender.Canvas.textOut(250,150,'Drag')
sender.Canvas.textOut(250,250,'↓↓')
p.caption=string.format('OnPaint: X:%s Y:%s',x,y)
end
OnPaint(f,20,180,200,60)
f.OnMouseDown=function(sender,button,x,y) xx,yy=x,y
f.tag=1
p.caption=string.format('MouePos: X:%s Y:%s',x,y)
if x>=f.Width-100 then f.dragNow() f.tag=0 end
end
f.OnMouseUp=function() f.tag=0 end
f.OnMouseMove=function(sender,x,y) if f.tag==1 then OnPaint(sender,xx,yy,x,y) end end
|
Description: |
|
Filesize: |
16.7 KB |
Viewed: |
1947 Time(s) |

|
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25778 Location: The netherlands
|
Posted: Mon Feb 22, 2021 8:38 am Post subject: |
|
|
yes, use math. I suck at it, but this seems to work somehow
Code: |
local dpiscale=192/getScreenDPI()
if f then f.Destroy() end
f=createForm()
--f.BorderStyle='bsNone'
f.Color=0x00ffff
f.setSize(800*dpiscale,600*dpiscale)
f.Position='poDesktopCenter'
f.FormStyle='fsSystemStayOnTop'
f.tag=0
p=createLabel(f)
p.Align='alBottom'
p.font.size=15
p.caption=string.format('OnPaint: X:%s Y:%s',x,y)
f.setLayeredAttributes(0xB4,230,3,3)
local xx , yy = 0 , 0
function OnPaint(sender,xx,yy,x,y)
sender.repaint()
sender.Canvas.Pen.Color=0x00
sender.Canvas.Pen.Width=dpiscale*4
sender.Canvas.Brush.Color=0xff
sender.Canvas.Brush.Style=1
--sender.Canvas.ellipse(xx,yy,x,y)
--sender.Canvas.roundRect(xx,yy,x,y,16,16)
sender.Canvas.line(xx,yy,x,y)
local angle=math.atan2(yy-y,xx-x)+0.8
local angle2=math.atan2(xx-x,yy-y)+0.8
sender.Canvas.line(x,y,x+(dpiscale*20)*math.cos(angle),y+(dpiscale*20)*math.sin(angle))
sender.Canvas.line(x,y,x+(dpiscale*20)*math.sin(angle2),y+(dpiscale*20)*math.cos(angle2))
sender.Canvas.textOut(250,50,'↑↑')
sender.Canvas.textOut(250,150,'Drag')
sender.Canvas.textOut(250,250,'↓↓')
p.caption=string.format('OnPaint: X:%s Y:%s A: %s',x,y, angle)
end
OnPaint(f,20,180,200,60)
f.OnMouseDown=function(sender,button,x,y) xx,yy=x,y
f.tag=1
p.caption=string.format('MouePos: X:%s Y:%s',x,y)
if x>=f.Width-100 then f.dragNow() f.tag=0 end
end
f.OnMouseUp=function() f.tag=0 end
f.OnMouseMove=function(sender,x,y) if f.tag==1 then OnPaint(sender,xx,yy,x,y) end end
|
_________________
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 |
|
 |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Mon Feb 22, 2021 9:02 am Post subject: |
|
|
Dark Byte wrote: | yes, use math. I suck at it, but this seems to work somehow | Before you reply, I am testing this code, ha ha.
But there is a problem, with the mouse moving drawing there will be flashing;
And how can I draw more arrows without clearing the previous ones
Description: |
|
Filesize: |
211.1 KB |
Viewed: |
1932 Time(s) |

|
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25778 Location: The netherlands
|
Posted: Mon Feb 22, 2021 9:14 am Post subject: |
|
|
draw to a bitmap with the same size and afterwards draw the bitmap to the window.
that will keep the arrow (and the rest) and solve the flickering
else keep a list of arrow positions and draw them each time. (I still recommend a bitmap to prevent flickering)
_________________
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 |
|
 |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Mon Feb 22, 2021 9:36 am Post subject: |
|
|
Dark Byte wrote: | draw to a bitmap with the same size and afterwards draw the bitmap to the window.
that will keep the arrow (and the rest) and solve the flickering
else keep a list of arrow positions and draw them each time. (I still recommend a bitmap to prevent flickering) |
I don't know how to use bitmap. Can you give me an example
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25778 Location: The netherlands
|
Posted: Mon Feb 22, 2021 10:26 am Post subject: |
|
|
Code: |
local dpiscale=192/getScreenDPI()
if f then f.Destroy() end
if bm then bm.destroy() end
f=createForm()
bm=createBitmap()
lines={}
--f.BorderStyle='bsNone'
f.Color=0x00ffff
f.setSize(800*dpiscale,600*dpiscale)
bm.Width=f.ClientWidth
bm.Height=f.ClientHeight
f.Position='poDesktopCenter'
f.FormStyle='fsSystemStayOnTop'
f.tag=0
p=createLabel(f)
p.Align='alBottom'
p.font.size=15
p.caption=string.format('OnPaint: X:%s Y:%s',x,y)
f.setLayeredAttributes(0xB4,230,3,3)
f.OnPaint=function(sender)
f.canvas.draw(0,0,bm)
end
local xx , yy = 0 , 0
function UpdateBitmapWithTempLine(sender,xx,yy,x,y)
local i
sender.canvas.brush.color=0xffff
sender.canvas.clear()
sender.Canvas.Pen.Color=0x00
sender.Canvas.Pen.Width=dpiscale*4
sender.Canvas.Brush.Color=0xff
sender.Canvas.Brush.Style=1
local angle
local angle2
--draw the previous lines
for i=1,#lines do
local xx=lines[i].startx
local yy=lines[i].starty
local x=lines[i].stopx
local y=lines[i].stopy
sender.Canvas.line(xx,yy,x,y)
angle=math.atan2(yy-y,xx-x)+0.8
angle2=math.atan2(xx-x,yy-y)+0.8
sender.Canvas.line(x,y,x+(dpiscale*20)*math.cos(angle),y+(dpiscale*20)*math.sin(angle))
sender.Canvas.line(x,y,x+(dpiscale*20)*math.sin(angle2),y+(dpiscale*20)*math.cos(angle2))
end
--draw the temporary line
sender.Canvas.line(xx,yy,x,y)
angle=math.atan2(yy-y,xx-x)+0.8
angle2=math.atan2(xx-x,yy-y)+0.8
sender.Canvas.line(x,y,x+(dpiscale*20)*math.cos(angle),y+(dpiscale*20)*math.sin(angle))
sender.Canvas.line(x,y,x+(dpiscale*20)*math.sin(angle2),y+(dpiscale*20)*math.cos(angle2))
--draw gui
sender.Canvas.textOut(f.Width-100*dpiscale,100*dpiscale,'↑↑')
sender.Canvas.textOut(f.Width-100*dpiscale,300*dpiscale,'Drag')
sender.Canvas.textOut(f.Width-100*dpiscale,500*dpiscale,'↓↓')
p.caption=string.format('OnPaint: X:%s Y:%s A: %s',x,y, angle)
f.repaint()
end
OnPaint(f,20,180,200,60)
f.OnMouseDown=function(sender,button,x,y)
xx,yy=x,y
f.tag=1
p.caption=string.format('MouePos: X:%s Y:%s',x,y)
if x>=f.Width-100 then f.dragNow() f.tag=0 end
end
f.OnMouseUp=function(sender, button, x,y)
f.tag=0
local a=(xx-x)*(xx-x)
local b=(yy-y)*(yy-y)
local c=math.sqrt(a+b)
if c>4 then
--only save long enough lines
local line={}
line.startx=xx
line.starty=yy
line.stopx=x
line.stopy=y
table.insert(lines, line)
end
end
f.OnMouseMove=function(sender,x,y) if f.tag==1 then UpdateBitmapWithTempLine(bm,xx,yy,x,y) end end
UpdateBitmapWithTempLine(bm,0,0,0,0)
|
_________________
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 |
|
 |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Mon Feb 22, 2021 10:56 am Post subject: |
|
|
Wow, that's great. That's what I want. Thank you very much.
Is it possible to clear one of the arrows? Or destroy it in the reverse order of the original drawing, because I see that a table is used in the code, and I wonder if it can be used to expand it
|
|
Back to top |
|
 |
|
|
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
|
|