Advertisement
Guest User

Variation on HelveticaClock with rotation

a guest
Nov 6th, 2014
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  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. translate_z -200
  7. rotate_x -180 * mouse_y / window_height
  8. rotate_y 180 * mouse_x / window_width
  9. translate_z 200
  10.  
  11. // Font and text alignment
  12. font "Arial", 300
  13. align 0.5
  14. align_vertically 0.5
  15.  
  16. // The size of the boxes used to show each digit
  17. once
  18. H := 1.1 * text_height "0"
  19. W := 1.1 * text_width "0"
  20.  
  21. shader_program
  22. fragment_shader <<
  23. void main()
  24. {
  25. vec4 color = gl_Color;
  26. color.a *= 1.0 - 8.0 * (gl_FragCoord.z - 0.5);
  27. gl_FragColor = color;
  28. }
  29. >>
  30.  
  31. // The primary draw loop
  32. locally
  33. Index := 0
  34. translate_x -2.5*W
  35. two_digits with hours, minutes, seconds
  36.  
  37. // Overlay to highlight the current time
  38. translate_z -20
  39. color_hsv 2 * time, 0.3, 0.5, 0.7
  40. rectangle 0, 0, 7*W, 1.1*H
  41.  
  42. // Drawing two digits
  43. two_digits N:integer -> digit_column with N/10, N mod 10
  44.  
  45. // Drawing a single digit column
  46. digit_column N:integer ->
  47. locally
  48. adjust -N, currentY[Index]
  49. digit with 0..9
  50.  
  51. // Move to the next one
  52. translate_x W
  53. Index := Index+1
  54.  
  55. // Drawing a single digit in a text box
  56. digit N:integer ->
  57. text_box 0,0,2*W,2*H,
  58. render N
  59. step 1
  60.  
  61. // Vertical adjustment - Common case
  62. adjust TY:real, Y:real ->
  63. interpolate 0.1, TY, Y
  64. step Y
  65.  
  66. // Vertical adjustment - Initialization case
  67. adjust TY:real, Other ->
  68. currentY[Index] := TY
  69. adjust TY, currentY[Index]
  70.  
  71. step R ->
  72. translate_z -400
  73. rotate_x 36 * R
  74. translate_z 400
  75.  
  76.  
  77. // The variables we use
  78. H -> 15.0
  79. W -> 15.0
  80. Index -> 0
  81. data currentY
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement