daily pastebin goal
33%
SHARE
TWEET

Helvetica Clock Chrome Experiment converted to Tao3D

a guest Nov 6th, 2014 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Animate
  2.  
  3. // Draw in white on a black background, rotate globally with the mouse
  4. background_color "black"
  5. color "white"
  6. rotate_x -180 * mouse_y / window_height
  7. rotate_y 180 * mouse_x / window_width
  8.  
  9. // Font and text alignment
  10. font "Arial", 300
  11. align 0.5
  12. align_vertically 0.5
  13.  
  14. // The size of the boxes used to show each digit
  15. once
  16.     H := 1.1 * text_height "0"
  17.     W := 1.1 * text_width "0"
  18.  
  19. // The primary draw loop
  20. locally
  21.     Index := 0
  22.     translate_x -2.5*W
  23.     two_digits with hours, minutes, seconds
  24.  
  25. // Overlay to highlight the current time
  26. blend_function "DST_COLOR", "ONE_MINUS_SRC_ALPHA"
  27. color_hsv 2 * time, 0.3, 0.5, 0.7
  28. rectangle 0, 0, 6.5*W, H
  29.  
  30. // Drawing two digits
  31. two_digits N:integer -> digit_column with N/10, N mod 10
  32.  
  33. // Drawing a single digit column
  34. digit_column N:integer ->
  35.     locally
  36.         adjust -N*H, currentY[Index]
  37.         digit with 0..9
  38.  
  39.     // Move to the next one
  40.     translate_x W
  41.     Index := Index+1
  42.  
  43. // Drawing a single digit in a text box
  44. digit N:integer ->
  45.     text_box 0,0,2*W,2*H,
  46.         render N
  47.     translate_y H
  48.  
  49. // Vertical adjustment - Common case
  50. adjust TY:real, Y:real ->
  51.     interpolate 0.1, TY, Y
  52.     translate_y Y
  53.  
  54. // Vertical adjustment - Initialization case
  55. adjust TY:real, Other ->
  56.     currentY[Index] := TY
  57.     adjust TY, currentY[Index}
  58.  
  59. // The variables we use
  60. H -> 15.0
  61. W -> 15.0
  62. Index -> 0
  63. data currentY
RAW Paste Data
Top