# Swiss clock scene - see end for credits
canvas width 800
canvas height 600
begin
load /assets/backgrounds/station-platform.png as platform
put platform as background
start swiss-clock 59 262 83 // scale, x, y
darken swiss-clock:clock to 40
scene swiss-clock
begin
# Pick up the parameters passed in to us
assign scale xpos ypos as $PARAMETERS
# Create nested groups, for the clock face and 2 hands
group create clock 200 200
group create hours in group clock size 200 200
group create minutes in group clock size 200 200
# get our local assets and turn them into group sprites
load swiss-railway-clock.png named clockface
load second-hand.png named second-hand
sprite create face in group clock from clockface
sprite create secondhand in group clock from second-hand
# place and darken the clockface to match the background image
place face at 100 100 size 200 200
# We are going to use graphic elements for the hour and minute hands
graphic create hourhand in group hours as rect 10 80
place hourhand at 100 62 200
graphic create minutehand in group minutes as rect 10 96
place minutehand at 100 53 206
place hours at 100 100 200
place minutes at 100 100 201
place secondhand at 100 100 202
# Clock is ready, now position it and set the current time
place clock at $xpos $ypos 100
scale clock to $scale
rotate minutes to ($MINUTES * 6)
rotate hours to ((($HOURS Mod 12) * 30) + ($MINUTES/2))
rotate secondhand to ($SECONDS * 6)
every 1 minute
# move both hands
rotate minutes to ($MINUTES * 6)
rotate hours to ((($HOURS Mod 12) * 30) + ($MINUTES/2))
every 1 second
rotate secondhand to ($SECONDS * 6)
description
Station platform generated by Canva AI / Affinity App
Clock face from https://commons.wikimedia.org/wiki/File:Swiss_railway_clock_1.svg
Call from URL /demo/swiss-clock/swiss-clock.txt
The scene swiss-clock can be reused as required
end description