yazdmich

Parametric plotter in OpenTuring

Oct 10th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. /*
  2. setup and variable declarations
  3. */
  4.  
  5. View.Set ('graphics:778;778,offscreenonly')
  6.  
  7. const midx := maxx div 2
  8. const midy := maxy div 2
  9.  
  10. type cart :
  11. record
  12. m : array 0 .. 778, 0 .. 778 of boolean
  13. x : array 0 .. 778 of int
  14. y : array 0 .. 778 of int
  15. z : array 0 .. 778 of int
  16. end record
  17.  
  18. var x, y, z : int
  19. var map : array 0 .. 360 of cart
  20.  
  21. /*
  22. begin program
  23. */
  24.  
  25. /*
  26. begin render and capture
  27. */
  28.  
  29. for q : 0 .. 360
  30. cls
  31. /*
  32. begin render of frame
  33. */
  34. for s : 0 .. midx
  35. for t : 1 .. midy
  36. map (q).x (s) := round (cosd (t) * s) + midx %---------------------------------%
  37. map (q).y (t) := round (sind (s) * t) + midy % calculate position of plot data %
  38. map (q).z (s) := t %---------------------------------%
  39. x := map (q).x (s) - midx
  40. z := map (q).z (s)
  41. x := round (cosd (q) * x - sind (q) * z) % calculate rotation around y-axis
  42. map (q).x (s) := x + midx
  43. Draw.Dot(map(q).x(s), map(q).y(t), black) % plot data
  44. end for
  45. end for
  46. /*
  47. end render of frame
  48. */
  49.  
  50. /*
  51. begin capture of frame
  52. */
  53. for i : 0 .. maxx
  54. for o : 0 .. maxy
  55. if whatdotcolour(i,o) = 7 then
  56. map(q).m(i,o) := true
  57. else
  58. map(q).m(i,o) := false
  59. end if
  60. end for
  61. end for
  62. /*
  63. end capture of frame
  64. */
  65.  
  66. View.Set ('title:Rendering: ' + realstr (round ((q / 360) * 1000) / 10, 3) + '% complete') % update title bar to show rendering status
  67. View.Update
  68. end for
  69.  
  70. /*
  71. end render and capture
  72. */
  73.  
  74. cls
  75. View.Update
  76. Input.Pause
  77.  
  78. /*
  79. begin playback
  80. */
  81.  
  82. loop
  83. for q : 0 .. 360
  84. cls
  85. for s : 0 .. maxx
  86. for t : 0 .. maxy
  87. if map(q).m(s,t) then
  88. Draw.Dot (s, t, black)
  89. end if
  90. end for
  91. end for
  92. View.Update
  93. end for
  94. cls
  95. Input.Pause
  96. end loop
Advertisement
Add Comment
Please, Sign In to add comment