Flip Numbers

By TheImrac on Nov 23, 2009

I got bored today and made a flip clock style counter, I plan to make it a clock when I get the time to dink around with it more.

Paste into the remote, type /clock and watch in awe!
Left click - pause/start
Right click - Close

code is a little sketchy

alias c1 {
  var %n = $1, %w = $2
  If (!$window(%w)) window -k0dhBpC +d %w 10 10 40 50
  ; else window -a %w
  clear -n %w
  drawrect -nrf %w $rgb(84,84,84) 0 0 0 40 25
  drawrect -nrf %w $rgb(70,70,70) 0 0 25 40 25
  drawrect -nr %w $rgb(0,0,0) 1 0 0 40 50
  drawtext -nro %w $rgb(115,115,115) arial 38 $round($calc(20 - $width(%n,arial,38,1)/2)),0) $round($calc(25 - $height(%n,arial,38)/2)),0) %n 
  drawtext -rco %w $rgb(155,155,155) arial 38 $round($calc(20 - $width(%n,arial,38,1)/2)),0) $round($calc(25 - $height(%n,arial,38)/2)),0) 40 $round($calc($height(%n,arial,38)/2),0) %n

}

alias c2 { 
  var %n = $1, %on = $2, %w = @ $+ $3, %tt = $4, %f = $5, %t1 = $+(@,$3,_,t1), %t2 = $+(@,$3,_,t2)
  If (!%tt || !%f) { 
    var %tt = $calc($ticks - 5), %f = 1 
    c1 %n %t1
    c1 %on %t2
    If (!$window(%w)) window -k0dBpC +d %w 10 10 40 50
    ;else window -a %w
  }
  ; If ($calc($ticks - %tt) >= 50) {
  If (%f <= 25) {
    clear -n %w
    drawcopy -n %t2 0 0 40 25 %w 0 0
    drawcopy -n %t1 0 25 40 25 %w 0 25
    var %h = $round($calc(25 - %f),0), %y = $round($calc(%f),0)
    drawcopy -n %t1 0 0 40 25 %w 0 %y 40 %h
  }

  ElseIf (%f > 25) {
    clear -n %w
    drawcopy -n %t2 0 0 40 25 %w 0 0
    drawcopy -n %t1 0 25 40 25 %w 0 25
    var %h = $calc(%f - 25)
    drawcopy -n %t2 0 25 40 25 %w 0 25 40 %h
  }
  drawdot %w
  If (%f >= 50) halt
  inc %f 5
  $+(.timer,%w) -m 1 25 c2 $1-3 $ticks %f
}

menu @clock {
  sclick:/timerclock $iif($timer(clock),off,0 1 t1)
  rclick:/timerclock off | /window -c @clock
}
alias t1 {
  inc %a 1
  if (%a = 10) %a = 0
  c2 $iif(%a == 0,9,$calc(%a - 1)) %a clock
}

alias clock {
  set %a 0
  timerclock 0 1 t1
}

Comments

Sign in to comment.
Testor   -  Nov 24, 2009

C1 and C2 aliases are probably going to conflict with many colour aliases, as lots of people use c1 + c2 as their colour aliases, so maybe not the best alias name to use for it :x.

 Respond  
cessil   -  Nov 24, 2009

oh wow that's cool

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.