It is currently Mon May 22, 2017 2:26 pm



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: A simple shadow clock.
Unread postPosted: Wed Dec 28, 2016 5:55 am 
Offline

Joined: Sat Mar 02, 2013 11:04 am
Posts: 836
Location: France
Hi folks,

A long time ago I saw this watch principle I can not remember where! Surely the kind Swatch :)

Code:
! Shadow clock @Cassiope34 12/16

GR.OPEN 255, 255, 255, 255, 0
gr.screen w,h
scx =1280 : scy =800
sx =w/scx : sy =h/scy
gr.scale sx,sy

CenterX = scx/2
CenterY = scy/2

GR.SET.STROKE 8

sz =scy/2.5

GR.BITMAP.CREATE minute, sz*2, sz*2   % minutes gradient of gray circle bitmap
gr.bitmap.drawinto.start minute
clr =120 : ctr =sz
for nm=360 to 0 step -1
  gr.color 255,clr,clr,clr,0
  y =ctr+sin(toradians(nm))*sz
  x =ctr+cos(toradians(nm))*sz
  gr.line nul, ctr, ctr, x, y
  if !mod(nm,2) then clr++ :clr =min(clr,255)
next
gr.bitmap.drawinto.end

sz =scy/1.8
GR.BITMAP.CREATE heure, sz, sz     % hours gradient of gray circle bitmap
gr.bitmap.drawinto.start heure
clr =130 : ctr =sz/2
for nm=0 to 360
  gr.color 200,clr,clr,clr,0
  y =ctr+sin(toradians(nm))*sz/2
  x =ctr+cos(toradians(nm))*sz/2
  gr.line nul, ctr, ctr, x, y
  if !mod(nm,2) then clr++ :clr =min(clr,255)
next
gr.bitmap.drawinto.end

sz =scy/2.5
GR.ROTATE.START 0, CenterX, CenterY, rotM       % object minute to rotate later...
gr.bitmap.draw nul, minute, CenterX-sz, CenterY-sz
GR.ROTATE.END

sz =scy/1.8
GR.ROTATE.START 0, CenterX, CenterY, rotH       % object hour to rotate later...
gr.bitmap.draw nul, heure, CenterX-sz/2, CenterY-sz/2
GR.ROTATE.END

sz =scy/2.5
GR.SET.STROKE 26
gr.color 255,180,180,180,0
gr.circle nul, CenterX, CenterY, sz+18    % gray circle around the clock
GR.SET.STROKE 4
gr.color 255,100,100,100,1
gr.circle nul, CenterX, CenterY, 10       % center point

gr.color 255,0,144,228,0     % blue clock numbers
gr.text.size 40
sz =scy/2.8 :c =3
for a=0 to 360
  if is_in("-"+int$(a)+"-","-30-60-90-120-150-180-210-240-270-300-330-360-")
    y =CenterX+sin(toradians(a))*sz
    x =CenterY+cos(toradians(a))*sz
    c =c+1-12*(c=12) : gr.text.draw nul, 226+x, -226+y, int$(c)
  endif
next

gr.color 255,255,148,8,1     % orange date
gr.text.size 32
GR.SET.STROKE 3
TIME ,,Day$, Hr$,,,wd
d$ ="Dim Lun Mar Mer Jeu Ven Sam Dim"
gr.text.draw nul, CenterX+80, CenterY+10, word$(d$,wd)+"  "+Day$

!gr.text.draw tmp,scx-200,40,""   % debug

GR.SET.STROKE 1
gr.color 255,0,0,0,0
gr.rect nul, CenterX+75, CenterY-18, CenterX+190, CenterY+15

GR.SET.STROKE 2           % green seconds pointer.
gr.color 255,25,180,0,1
sz =scy/3
gr.line sec, CenterX, CenterY, CenterX, CenterY

timer.set 1000     % so maj every second !!

TIME ,,, Hr$, Mn$             %  display the actual time.
oldmnt =val(Mn$) : oldhre =val(Hr$)
if oldmnt>=15 then mAng =(oldmnt-15)*6 else mAng =270+oldmnt*6
gr.modify rotM, "angle", mAng
if oldhre>=3 then hAng =(oldhre-3)*30 else hAng =270+oldhre*30
gr.modify rotH, "angle", hAng + oldmnt/2
gr.render

DO
  pause 100
UNTIL 0
timer.clear
END         % ----------------------- exit ----------------------------

OnTimer:
TIME ,,, Hr$, Mn$, Sc$
scd =val(Sc$) : mnt =val(Mn$) : hre =val(Hr$)
if scd>=15 then sAng =(scd-15)*6 else sAng =270+scd*6
sy =sin(toradians(sAng))*sz     % seconds
sx =cos(toradians(sAng))*sz
gr.modify sec, "x2", CenterX+sx, "y2", CenterY+sy

if mnt<>oldmnt
   if mnt>=15 then mAng =(mnt-15)*6 else mAng =270+mnt*6
   gr.modify rotM, "angle", mAng
   oldmnt =mnt
   hdelta =int(mnt/2)
   if hre<>oldhre
     if hre>=3 then hAng =(hre-3)*30 else hAng =270+hre*30
     hdelta =0 : oldhre =hre
   endif
   gr.modify rotH, "angle", hAng + hdelta
endif
!gr.modify tmp, "text", Hr$+":"+Mn$+":"+Sc$

GR.RENDER
Timer.Resume


Cheers

Gilles

_________________
"It is better to mobilize intelligence for stupid things, rather than mobilizing stupidity for intelligent things."
Galaxy TAB S 8.4, 2560x1600, Marshmallow 6.0.1
Galaxy Note II, 1280x720, JB4.1.2
Galaxy A3, 1280x720, Android 6.0.1


Report this post
Top
 Profile  
 
 Post subject: Re: A simple shadow clock.
Unread postPosted: Wed Dec 28, 2016 11:35 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1336
Lovely clock, Gilles.

I guess 'Mer' is your language for Dec (December) ;)

Regards Roy
Attachment:
clock.PNG
clock.PNG [ 101.72 KiB | Viewed 597 times ]


Report this post
Top
 Profile  
 
 Post subject: Re: A simple shadow clock.
Unread postPosted: Wed Dec 28, 2016 12:13 pm 
Offline

Joined: Sat Mar 02, 2013 11:04 am
Posts: 836
Location: France
roy wrote:
Lovely clock, Gilles.

I guess 'Mer' is your language for Dec (December) ;)

Regards Roy


Eeeeuh ! :oops: :oops: sorry no roy : just for Wednesday :oops:

You can change it! see the code :oops:

Cheers

Gilles.

_________________
"It is better to mobilize intelligence for stupid things, rather than mobilizing stupidity for intelligent things."
Galaxy TAB S 8.4, 2560x1600, Marshmallow 6.0.1
Galaxy Note II, 1280x720, JB4.1.2
Galaxy A3, 1280x720, Android 6.0.1


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
suspicion-preferred