// enter program
norefresh

//This is intended to be a clock of sorts...

//The movement on the left is a continuous flow, while the 
//movement on the right happens in discrete parts.  

//The shapes on the right together form a left to right 
//color gradient, while the shapes on the left are all the same color.




set ppr 20

paper ppr

set len 1
set offset 10
set x1 10
set x2 20

set pos 0

command setblocks p num
{
   //does a binary counting thing with little blocks
   set w 10
   set h 10
   set sx 41
   set sy 30
   set n (num % 64)
   set p (p%6)
   set y1 (sy + p*h)
   set y2 (sy - 2 + (p+1)*h)
   field sx y1 100 y2 ppr
   same? (n/32) 1
   { 
      set b (sx + w-2)
      field sx y1 b y2 30
      set n (n%32)
   }
   same? (n/16) 1
   {
      field (sx+w) y1 (sx+2*w-2) y2 40
      set n (n%16)
   }
   same? (n/8) 1
   {
      set a (sx+(2*w))
      set c (sx+(3*w)-2)
      field a y1 c y2 55
      set n (n%8)
   }
   same? (n/4) 1
   {
      field (sx+3*w) y1 (sx+4*w-2) y2 70
      set n (n%4)
   }
   same? (n/2) 1
   {
      set a (sx+4*w)
      set c (sx+5*w-2)
      field a y1 c y2 85
      set n (n%2)
   }
   same? (n/1) 1
   {
      field (sx+5*w) y1 (sx+6*w-2) y2 100
      set n (n%1)
   }
}
 
set count -1
set val 0

forever
{
   set pos ((pos + 1) % 10000)
   pause 10
   field x1 0 x2 100 ppr
   repeat i 1 30
   {
      field x1 (((pos+i*offset) % 300)-20) x2 (((pos+i*offset) % 300)-20+len) 100
   }
   field 37 30 38 88 90
   same? 0 (pos % 10)
   {
     set count ((count+1)%100)
     set val ((val+1)%100)
     setblocks count (val*2)
   }
   refresh
}