|
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: 189
|
Posted: Tue Jan 21, 2020 11:23 am Post subject: Use canvas to add shadow to control |
|
|
This is a blurred shadow painted on the canvas, it has no transparency, I can adjust the position and size. Can you help me optimize it? I know there are many problems with this code Code: | if f then f.Destroy() end
f=createForm()
f.BorderStyle='bsSizeable'
f.Color=0xff
f.setSize(400,350)
f.setPosition(330,50)
p1=createPanel(f)
p1.setSize(100,100)
p1.setPosition(50,70)
p1.BevelOuter='bvNone'
p1.color=0xffff
p2=createPanel(f)
p2.setSize(100,100)
p2.setPosition(230,70)
p2.BevelOuter='bvNone'
p2.color=0xffff00
p3=createPanel(f)
p3.setSize(100,100)
p3.setPosition(50,200)
p3.BevelOuter='bvNone'
p3.color=0xff00ff
function setShadow(form,control)
local v=5
local size=40
local L=control.Left
local T=control.Top
local W=control.Width
local H=control.Height
form.OnPaint=function()
form.Canvas.Clear()
for j=1,size do
form.Canvas.Pen.Color=form.color-j*v
for i=1,size-j*2 do
form.Canvas.Pen.Width=i--i+W/2
form.Canvas.roundRect(L,T,L+W,T+H,10,10)
end
end
end form.repaint()
end
setShadow(f,p3)
--setShadow(f,p2)
--setShadow(f,p3) | I changed some more code. It can now be displayed around the control. You'd better optimize the code again
Last edited by .lua on Wed Jan 22, 2020 12:18 am; edited 2 times in total |
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Jan 21, 2020 6:25 pm Post subject: |
|
|
First, sorry if out of topic and I don't know if roundRect() shall work in code below, but for a object shadow I am use something like this.
Code: | if f then f.Destroy() end
f=createForm()
f.BorderStyle='bsSizeable'
f.Color=0x0ff
f.setSize(400,250)
f.setPosition(330,50)
p1=createPanel(f)
p1.setSize(100,100)
p1.setPosition(50,70)
p1.BorderStyle = 'bsNone'
p1.color=0xffff
bmp = createBitmap()
bmp.Width = p1.Width + 20
bmp.Height = p1.Height + 40
bmp.Left = p1.Top - 30
bmp.Top = p1.Top - 30
bmp.Canvas.gradientFill(0,10,bmp.width,bmp.height, 0x0000FF,0x000CCC,1) -- Adjust shadow effect here
pbx = createPaintBox(f)
pbx.Width = p1.Width + 20
pbx.Height = p1.Height + 40
pbx.Top= p1.Left - 10
pbx.Left= p1.Top - 30
Bitmap = createBitmap(pbx.Width, pbx.Height)
Bitmap.TransparentColor = 0
Bitmap.Transparent = true
local function updateBitM()
Bitmap.Canvas.clear();
Bitmap.Canvas.roundRect(0,0,pbx.Width,pbx.Height);
Bitmap.Canvas.Draw(0,0, bmp)
local t=createBitmap()
t.Canvas.Brush.Color=0x00 --0xffffff
t.Canvas.Pen.Color=0xffffff
t.transparent=true
t.TransparentColor=0xffff00
t.Width=120
t.Height=20
t.Top=10
t.Left=15
Bitmap.Canvas.Draw(0,0,t) -- change 0,0 as coordinate to get effect
t.destroy()
end
pbx.onPaint = function ()
updateBitM()
pbx.Canvas.clear()
pbx.Canvas.draw(0,0,Bitmap);
local r = pbx.Canvas.getClipRect();
pbx.Canvas.drawWithMask(r.Left,r.Top,r.Right, r.Bottom,Bitmap,r.Left, r.Top,r.Right,r.Bottom)
end
pbx.onClick = function ()
pbx.repaint()
end |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1253
|
Posted: Wed Jan 22, 2020 2:46 am Post subject: |
|
|
Why are you dealing with complex codes?
Sometimes simple codes can save time and code.
Code: | if f then f.Destroy() end
f=createForm()
f.BorderStyle='bsSizeable'
f.Color=0x0ff
f.setSize(400,250)
f.setPosition(330,50)
p1=createPanel(f)
p1.setSize(100,100)
p1.setPosition(50,70)
p1.BorderStyle = 'bsNone'
p1.color=0xffff
p2=createPanel(f)
p2.setSize(100,100)
p2.setPosition(240,70)
p2.BorderStyle = 'bsNone'
p2.color=0xff22
l1=createLabel(f)
l1.setPosition(100,200)
l1.Font.Style = "fsBold"
l1.Font.Size = 10
--l1.Color = 0x0000CC
l1.caption = "Example Shadow"
l1.Font.color=0xffff
l1.bringToFront()
function Shadow1(f, shdPan, Left, Top)
local p3=createPanel(f)
p3.Width = shdPan.Width
p3.Height = shdPan.Height
p3.Left = shdPan.left - Left
p3.Top = shdPan.Top - Top
p3.BorderStyle = 'bsNone'
p3.color=0x00009C
p3.BevelOuter = "bvNone"
p3.sendToBack()
end
Shadow1(f, p1, 10, 10)
Shadow1(f, p2, 10, 10)
Shadow1(f, l1, 4, 4) --Label will not work effectively |
----------------------------------------------------
@Corroder code works fine, but for more panels, it is necessary to rewrite the code again and again.
Code: | if f then f.Destroy() end
f=createForm()
f.BorderStyle='bsSizeable'
f.Color=0x0ff
f.setSize(400,250)
f.setPosition(330,50)
p1=createPanel(f)
p1.setSize(100,100)
p1.setPosition(50,70)
p1.BorderStyle = 'bsNone'
p1.color=0xffff
p2=createPanel(f)
p2.setSize(100,100)
p2.setPosition(240,70)
p2.BorderStyle = 'bsNone'
p2.color=0xff22
bmp = createBitmap()
bmp.Width = p1.Width
bmp.Height = p1.Height + 20
bmp.Left = p1.left - 30
bmp.Top = p1.Top - 30
bmp.Canvas.gradientFill(0,10,bmp.width,bmp.height, 0x00008F,0x0000CC,1) -- Adjust shadow effect here
pbx = createPaintBox(f)
pbx.Width = p1.Width -- + 20
pbx.Height = p1.Height + 20
pbx.Top= p1.Top - 30
pbx.Left= p1.Left - 10
------------------------------
bmp1 = createBitmap()
bmp1.Width = p2.Width
bmp1.Height = p2.Height + 20
bmp1.Left = p2.left - 30
bmp1.Top = p2.Top - 30
bmp1.Canvas.gradientFill(0,10,bmp1.width,bmp1.height, 0x00008F,0x0000CC,1) -- Adjust shadow effect here
pbx1 = createPaintBox(f)
pbx1.Width = p2.Width -- + 20
pbx1.Height = p2.Height + 20
pbx1.Top= p2.Top - 30
pbx1.Left= p2.Left - 10
--------------------------------
Bitmap = createBitmap(pbx.Width, pbx.Height, pbx1.Width, pbx1.Height)
Bitmap.TransparentColor = 0
Bitmap.Transparent = true
local function updateBitM()
Bitmap.Canvas.clear();
Bitmap.Canvas.roundRect(0,0,pbx.Width,pbx.Height,pbx1.Width,pbx1.Height);
Bitmap.Canvas.Draw(0,0, bmp)
Bitmap.Canvas.Draw(0,0, bmp1)
local t=createBitmap()
t.Canvas.Brush.Color=0x00 --0xffffff
t.Canvas.Pen.Color=0xffffff
t.transparent=true
t.TransparentColor=0xffff00
t.Width=120
t.Height=20
t.Top=10
t.Left=15
Bitmap.Canvas.Draw(0,0,t) -- change 0,0 as coordinate to get effect
t.destroy()
end
pbx.onPaint = function ()
updateBitM()
pbx.Canvas.clear()
pbx.Canvas.draw(0,0,Bitmap);
local r = pbx.Canvas.getClipRect();
pbx.Canvas.drawWithMask(r.Left,r.Top,r.Right, r.Bottom,Bitmap,r.Left, r.Top,r.Right,r.Bottom)
end
pbx1.onPaint = function ()
updateBitM()
pbx1.Canvas.clear()
pbx1.Canvas.draw(0,0,Bitmap);
local r1 = pbx1.Canvas.getClipRect();
pbx1.Canvas.drawWithMask(r1.Left,r1.Top,r1.Right, r1.Bottom,Bitmap,r1.Left, r1.Top,r1.Right,r1.Bottom)
end
pbx.onClick = function ()
pbx.repaint()
pbx1.repaint()
end |
Of course, the final decision is yours.
_________________
|
|
Back to top |
|
|
.lua Expert Cheater Reputation: 1
Joined: 13 Sep 2018 Posts: 189
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1253
|
Posted: Wed Jan 22, 2020 5:22 am Post subject: |
|
|
and I still believe in the magic of simple codes.
Open the limit of your imagination.
Code: | if f then f.Destroy() end
f=createForm()
f.BorderStyle='bsSizeable'
f.Color=0x0ff
f.setSize(400,250)
f.setPosition(330,50)
p1=createPanel(f)
p1.setSize(300,70)
p1.setPosition(50,20)
p1.BorderStyle = 'bsNone'
p1.color=0xffff
p2=createPanel(f)
p2.setSize(300,70)
p2.setPosition(50,130)
p2.BorderStyle = 'bsNone'
p2.color=0xff22
l1=createLabel(f)
l1.setPosition(100,230)
l1.Font.Style = "fsBold"
l1.Font.Size = 10
--l1.Color = 0x0000CC
l1.caption = "Example Shadow"
l1.Font.color=0xffff
l1.bringToFront()
function Shadow1(f, shdPan, Left, Top)
local i3=createImage(f)
i3.Width = shdPan.Width
i3.Height = shdPan.Height
i3.Left = shdPan.left + Left
i3.Top = shdPan.Top + Top
i3.AutoSize=false
i3.Stretch=true
i3.picture.loadFromStream(findTableFile("shadw03.png").stream)
i3.sendToBack()
end
Shadow1(f, p1, 0, 10)
Shadow1(f, p2, 0, 10)
Shadow1(f, l1, 0, 1) --Label will not work effectively |
and Shadow 2:
Code: | function Shadow2(f, shdPan, Left, Top)
local i4=createImage(f)
i4.Width = shdPan.Width + 60
i4.Height = shdPan.Height + 60
i4.Left = shdPan.left + Left
i4.Top = shdPan.Top + Top
i4.AutoSize=false
i4.Stretch=true
i4.picture.loadFromStream(findTableFile("shadw05.png").stream)
i4.sendToBack()
end
Shadow2(f, p2, -30, -30) |
Description: |
|
Filesize: |
65.38 KB |
Viewed: |
1829 Time(s) |
|
Description: |
|
Filesize: |
35.81 KB |
Viewed: |
1829 Time(s) |
|
Description: |
|
Filesize: |
52.14 KB |
Viewed: |
1829 Time(s) |
|
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Wed Jan 22, 2020 6:05 am Post subject: |
|
|
Aylin wrote: |
@Corroder code works fine, but for more panels, it is necessary to rewrite the code again and again.
|
Okay, then I just see this word on the post title, he said 'CANVAS' not use 'IMAGE' as object shadow. So, I give an example using canvas for object shadow.
and "it is necessary to rewrite the code again and again", of course not, because I believe if someone knows about Lua scripting, he able to create a Lua function for the general object purpose from my example code above. That's it.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
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
|
|