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 


CE Analog clock method. Manual / Plugin

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions
View previous topic :: View next topic  
Author Message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Wed Feb 26, 2020 1:57 pm    Post subject: CE Analog clock method. Manual / Plugin Reply with quote

CE Anolog clock method. Manual / Plugin
something = requires (something.lua or dll)
something else = requires (somethingElse.lua or dll)

CE can perform many functions without requiring it.
I believe it. CE Masters are good coders.
Here is the Analog clock method and requires only CE.


Code:
function ClockMaker(f, height1, width1, leftX, topY)
local item = createImage(f)
item.Height=height1
item.Width=width1
item.Left=leftX
item.Top=topY
item.Stretch = true
local x0=tonumber(item.width / 2)
local y0=tonumber(item.height / 2)
local x10=tonumber(item.width / 2)
local y10=tonumber(item.height / 2)
local x20=tonumber(item.width / 2)
local y20=tonumber(item.height / 2)
local xx=tonumber(item.width / 2)

local r = y0 - 20
local x = x0
local x1 = x10
local x2 = x20
local xx1=item.Width/6
------------------------------------

if ix3 then ix3.destroy() ix3 = nil end
local ix3 = createLabel(f)
ix3.Font.Size = item.Width / 12
ix3.Font.Style = "fsBold"
ix3.Font.Color = "0x00FF00"
ix3.AutoSize = false
ix3.Alignment= "taCenter"
ix3.Height = item.Height / 8
ix3.Width = item.Width / 2
ix3.Left = item.Left + 80
ix3.Top = item.Top + item.Height - 80

local s = tonumber(os.date('%S'))
local m2 = tonumber(os.date('%M')) * 60
local h2 = tonumber(os.date('%I')) * 3600
--print(h2.." - "..m2.." - "..s)

local m = tonumber(os.date('%M')) local h = tonumber(os.date('%I'))
-------------------------------------
function test(timer)
local x,y = item.screenToClient(x,y)

local bm=item.picture.Bitmap
bm.Width=item.Width
bm.Height=item.Height
local Canvas = bm.Canvas

  Canvas.clear()
bm.Canvas.Brush.Color="0x2000a0";
bm.Canvas.roundRect(0, 0, item.Height, item.Width, item.Height, item.Width);

 r = math.random(x0)
 y = y0 - r
  if r < xx then r=xx end
 s = s + 1
 x = x0 + math.floor(r * math.sin(s * math.pi/30))
 y = y0 - math.floor(r * math.cos(s * math.pi/30))

 r = math.random(x10)
  if r then r=xx - 15 end
local x1,y1 = item.screenToClient(x1,y1)
 y1 = y10 - r
 m2 = m2 + 1
 x1 = x10 + math.floor(r * math.sin(m2 * math.pi/1800))
 y1 = y10 - math.floor(r * math.cos(m2 * math.pi/1800))
  if r then r=xx - 40 end
local x2,y2 = item.screenToClient(x2,y2)
 y2 = y20 - r
 h2 = h2 + 1
 x2 = x20 + math.floor(r * math.sin(h2 * math.pi/21000))
 y2 = y20 - math.floor(r * math.cos(h2 * math.pi/21000))
  Canvas.pen.Color = "0xFFFFFF"
  Canvas.pen.Width = 2
  Canvas.line(x, y, xx, xx) --s
  Canvas.pen.Color = "0xFFFF00"
  Canvas.pen.Width = 5
  Canvas.line(x1, y1, xx, xx) --d
  Canvas.pen.Color = "0x00ffff"
  Canvas.pen.Width = 7
  Canvas.line(x2, y2, xx, xx) --h
  Canvas.pen.Color = "0xFF9000"
  Canvas.pen.Width = 3
  Canvas.line(xx1*6, xx1*3, xx1*5, xx1*3) --15 >> 3
  Canvas.line(xx1*3, xx1*6, xx1*3, xx1*5) --30 >> 6
  Canvas.line(0, xx1*3, xx1, xx1*3) --45 >> 9
  Canvas.line(xx1*3, xx1, xx1*3, 0) --60 >> 0-12

bm.TransparentColor=clBlack
item.Transparent=true
if s >= 60 then s=0  m=m + 1 end
if m >= 60 then m=0 h=h + 1 end
if h >= 13 then h=1 end
------------------------------------
  ix3.caption=(h..":"..m..":"..s)
ix3.bringToFront()
end

if t then t.destroy(); t=nil end
t=createTimer()
t.Interval = 1000
t.onTimer = test
end
--use of
--ClockMaker(f, height1, width1, leftX, topY)
--form = you Trainer name
ClockMaker(form, 200, 200, 120, 120)


Note; The codes on the market are blended. A clock image can be added to the developable background. (ClockFon.JPG)

Enjoy it! Wink



ClockFon.JPG
 Description:
 Filesize:  77 KB
 Viewed:  10095 Time(s)

ClockFon.JPG



ClockMaker.lua
 Description:

Download
 Filename:  ClockMaker.lua
 Filesize:  2.88 KB
 Downloaded:  535 Time(s)


_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Feb 27, 2020 10:26 am    Post subject: Reply with quote

Good work!. Congratulations!

I have tested your script whit just make a form and the result as shown on the attached picture and I have my own created too.



AylinClock.JPG
 Description:
Tested Aylin Clock
 Filesize:  15.88 KB
 Viewed:  9425 Time(s)

AylinClock.JPG



VCLCircularClock.JPG
 Description:
VCL Circular Clock
 Filesize:  29.13 KB
 Viewed:  9425 Time(s)

VCLCircularClock.JPG



_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Thu Feb 27, 2020 3:52 pm    Post subject: Reply with quote

The main structure of the code is already @Corroder from your archive. Smile
This is the feasibility coding for "Anolog Clock" only.
It requires a lot of Mathematics, and nobody, the hour in my script, noticed the wrong mathematics of the "Scorpio" hand. Wink
If I find a free time, I will also deploy lines 1-12.
But as I said, it requires a lot of math.

Note; If it won't block you, you can share the code in the picture.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Feb 27, 2020 6:40 pm    Post subject: Reply with quote

What I mean is your clock isn't center on the form.
It's not too much math calculation for draw clock hand. Below are the functions I used to calculate the degree for each clock hands.


Code:
abs = math.abs
sin = math.sin
cos = math.cos
rad = math.rad

function getLocalDateTime()
  datetime = os.date("*t")
  return datetime
end

function clock12ToDeg(clockVal)
  if clockVal >= 12 then clockVal = clockVal-12 end
  degVal = 90 - (30 * clockVal)
  return degVal
end

function clock60ToDeg(clockVal)
  if clockVal >= 60 then clockVal = clockVal-60 end
  degVal = 90 - (6 * clockVal)
  return degVal
end

function degToClock(degree, r,x,y)
  if x == nil then x = clockX end
  if y == nil then y = clockY end
  if r == nil then r = clockR end
  -- get position of a clock hand's degree
  mx = x + r * cos(rad(degree))
  my = y + r * sin(rad(degree))
  return mx, my
end



You said:
....... and nobody, the hour in my script, noticed the wrong mathematics of the "Scorpio" hand.

I think is too difficult to understand with your statement above, so maybe because of that, you got no response from peoples.
Event me, don't know what is mean the 'Scorpio' hand.
Maybe more easy to understand if you said 'hour hand', 'minute hand' and 'second hand' or 'clock long hand', 'clock short hand' and 'clock seconds hand'.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Fri Feb 28, 2020 1:13 am    Post subject: Reply with quote

If it's used for the form, just edit the code below.
Code:
ClockMaker(form, 200, 200, 120, 120)
--or
--ClockMaker(form, 240, 240, 10, 10)
--or
--ClockMaker(form, 100, 100, 110, 110)
--or
--ClockMaker(UDF1, UDF1.CEImage1.Height - 60, UDF1.CEImage1.Width - 60, UDF1.CEImage1.Left + 30, UDF1.CEImage1.Top + 30)

------------------------------
Translation; Although I wrote it as "needle", it gave the result "Hand".
But I think some terms are global;
Scorpio, minute hand etc.
Understood; "Hand" if written alone,
If it is written in the clock method; "Scorpio hand - Hour hand" etc.
------------------------------
What I mean by mathematics;


Code:
if form then form.destroy() form = nil end
if t then t.destroy() t = nil end

if syntaxcheck then return end
if not form then
  form = createForm()
  form.Height = 360
  form.Width = 360
  form.caption="CE Analog Clock v1"
--form.Position = poDesktopCenter
  form.OnClose = function()
    form = nil
    return caFree
  end
end

local ix2 = createImage(form)
ix2.Height = form.Height - 110
ix2.Left = 55
ix2.Top = 55
ix2.Width = form.Width - 110
ix2.Stretch = true

local ix3 = createLabel(form)
ix3.Font.Size = 20
ix3.Font.Style = "fsBold"
ix3.Font.Color = "0x00FF00"
ix3.AutoSize = false
ix3.Alignment= "taCenter"
ix3.Height = 35
ix3.Width = 120
ix3.Left = 121
ix3.Top = 190

local ix4 = createLabel(form)
ix4.Font.Size = 20
ix4.Font.Style = "fsBold"
ix4.Font.Color = "0x00FF00"
ix4.AutoSize = false
ix4.Alignment= "taCenter"
ix4.Height = 35
ix4.Width = 120
ix4.Left = 121
ix4.Top = 220

local x0=120
local y0=120
local s = 0 --tonumber(os.date('%S'))
local m = 0
local h = 12

local m2 = 0
local h2 = 0
local r = y0 - 20
local x = x0

function test(timer)
local s1 = tonumber(os.date('%S'))
local m1 = tonumber(os.date('%M'))
local h1 = tonumber(os.date('%I'))

  if not form and t then t.destroy(); t=nil return end

local x,y = ix2.screenToClient(x,y)

bm=ix2.picture.Bitmap
bm.Width=ix2.Height
bm.Height=ix2.Width
local Canvas = bm.Canvas

  Canvas.clear()
bm.Canvas.Brush.Color="0x2000a0";
bm.Canvas.roundRect(0, 0, 240, 240, 240, 240);

 r = math.random(x0)
 y = y0 - r
  if r < 120 then r=120 end
 s = s + 1
 x = x0 + math.floor(r * math.sin(s * math.pi/30))
 y = y0 - math.floor(r * math.cos(s * math.pi/30))
 --m = m + 1
  if r then r=90 end
 x1 = x0 + math.floor(r * math.sin(m2 * math.pi/1800))
 y1 = y0 - math.floor(r * math.cos(m2 * math.pi/1800))
 m2 = m2 + 1
  if r then r=70 end
 x2 = x0 + math.floor(r * math.sin(h2 * math.pi/18000))
 y2 = y0 - math.floor(r * math.cos(h2 * math.pi/18000))
 h2 = h2 + 1
  Canvas.pen.Color = "0xFFFFFF"
  Canvas.pen.Width = 2
  Canvas.line(x, y, 120, 120) --s
  Canvas.pen.Color = "0xFFFF00"
  Canvas.pen.Width = 5
  Canvas.line(x1, y1, 120, 120) --d
  Canvas.pen.Color = "0x00ffff"
  Canvas.pen.Width = 7
  Canvas.line(x2, y2, 120, 120) --h
  --print(s.."- x: "..x.." y: "..y.." r: "..r) --120, 120)
  Canvas.pen.Color = "0xFF0000"
  Canvas.pen.Width = 3

---- Here is Mathematics :)

  Canvas.line(165, 40, 179, 17) --5 >> 1
  Canvas.line(195, 77, 223, 60) --10 >> 2
  Canvas.line(240, 120, 200, 120) --15 >> 3
  Canvas.line(190, 160, 223, 180) --20 >> 4
  Canvas.line(163, 195, 179, 224) --25 >> 5
  Canvas.line(120, 240, 120, 200) --30 >> 6
  Canvas.line(77, 195, 60, 224) --35 >> 7
  Canvas.line(45, 165, 16, 181) --40 >> 8
  Canvas.line(0, 120, 40, 120) --45 >> 9
  Canvas.line(47, 77, 16, 60) --50 >> 10
  Canvas.line(76, 45, 60, 17) --55 >> 11
  Canvas.line(120, 40, 120, 0) --60 >> 0-12

bm.TransparentColor=clBlack
ix2.Transparent=true
ix3.bringToFront()
if s > 60 then s=0  m=m + 1 end
if m > 60 then m=0 h=h + 1 end
if h > 13 then h=1 end
  ix3.caption=(h1..":"..m1..":"..s1)
  ix4.caption=(h..":"..m..":"..s)
end

if t then t.destroy(); t=nil end
t=createTimer()
t.Interval = 1000
t.onTimer = test


It is overwritten a lot, but it is a beginner level to edit. Smile

Note: You have nice coding, congratulations @Corroder

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Feb 28, 2020 12:10 pm    Post subject: Reply with quote

Good idea, but the clock time not set to local time and between analog vs digital doesn't match.


Capture.JPG
 Description:
 Filesize:  75.69 KB
 Viewed:  9300 Time(s)

Capture.JPG



_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Fri Feb 28, 2020 4:51 pm    Post subject: Reply with quote

From another project it was irregular sharing.
When I thought of mathematics, I left it halfway.
My first code has a local time compatibility detail. Wink
Just change the code below.


Code:

--local s = 0 --tonumber(os.date('%S'))
local m = 0
local h = 0

local s = tonumber(os.date('%S'))
local m2 = tonumber(os.date('%M')) * 60
local h2 = tonumber(os.date('%I')) * 3000 --The watch may request compliance math. 3000 works fine for me.
local r = y0 - 20
local x = x0


OK. I will create a regular code.
I will add a few more details.
I will publish when it is finished. Smile

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions 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