home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacHaskell 2.2 / progs / demo / X11 / animation / r_constants.hs < prev    next >
Encoding:
Text File  |  1994-09-27  |  2.8 KB  |  130 lines  |  [TEXT/YHS2]

  1. {-****************************************************************
  2.    MODULE R_CONSTANTS
  3.  
  4.      This module sets up all the constants used in this functional
  5.    animation package.
  6.      Defined here are the basic units of movement, scale and rotation.
  7.    The screen height and width are set, and the various parts of
  8.    the screen such as the top-middle, lower-left and center are
  9.    all set. Finally the color values used by xcshow, the c-program
  10.    that displays the movies in X, are set.
  11.  
  12. ******************************************************************-}
  13.  
  14. module R_Constants (fps, unit, hf, qt, scaleunit, rotunit,
  15.                     nullpic, nullseq,
  16.                     sinunit,cosunit,
  17.                     screenwid, screenht, botl, leftm, topl, topm, topr,
  18.                     rightm, botr, botm, center,
  19.             white,black,red,green,darkblue,lightblue,brown,yellow,
  20.             colorName, allColors
  21.             ) where
  22.  
  23. import R_Ptypes
  24.  
  25.   -- units are set. The scaleunit is in 11th, so that the 12 is
  26.   -- actually 12/11'ths
  27. fps :: Int
  28. unit :: Int
  29. hf :: Int
  30. qt :: Int
  31. scaleunit :: Int
  32. fps = 25
  33. unit = 15
  34. hf =  unit `div` 2
  35. qt =  unit `div`4
  36. scaleunit = 12
  37.   --scaleunit is div'ed by 12 later
  38.  
  39. rotunit :: Float
  40. rotunit  = pi/18
  41. sinunit  = sin rotunit
  42. cosunit  = cos rotunit
  43.  
  44.  
  45. nullpic :: Pic
  46. nullpic = []
  47. nullseq :: Movie
  48. nullseq= nullpic : [ nullseq2 | nullseq2 <- nullseq]
  49.  
  50.   -- Screen Parameters
  51. screenwid :: Int
  52. screenwid = 800
  53. screenht :: Int
  54. screenht  = 800
  55.  
  56. botl :: Vec
  57. leftm :: Vec
  58. topl :: Vec
  59. topm :: Vec
  60. topr :: Vec
  61. rightm :: Vec
  62. botr :: Vec
  63. botm :: Vec
  64. center :: Vec
  65.  
  66. leftmb :: Vec
  67. leftmt :: Vec
  68. topml :: Vec
  69. topmr :: Vec
  70. rightmt :: Vec
  71. rightmb :: Vec
  72. botml :: Vec
  73. botmr :: Vec
  74.  
  75. botl   = ( 0, 0 )
  76. leftm  = ( 0, screenht `div` 2)
  77. topl   = ( 0, screenht )
  78. topm   = ( screenwid `div` 2, screenht )
  79. topr   = ( screenwid, screenht )
  80. rightm = ( screenwid, screenht `div` 2 )
  81. botr   = ( screenwid, 0 )
  82. botm   = ( screenwid `div` 2, 0 )
  83. center = ( screenwid `div` 2, screenht `div` 2 )
  84.  
  85. leftmb  = ( 0, screenht `div` 4 )
  86. leftmt  = ( 0, (screenht*3) `div` 4 )
  87. topml   = ( screenwid `div` 4, screenht )
  88. topmr   = ( (screenwid*3) `div` 4, screenht )
  89. rightmt = ( screenwid, (screenht*3) `div` 4 )
  90. rightmb = ( screenwid, screenht `div` 4 )
  91. botml   = ( screenwid `div` 4, 0 )
  92. botmr   = ( (screenwid*3) `div` 4, 0 )
  93.  
  94.   -- Colors values set to names
  95.  
  96. white :: Color
  97. white = 1
  98. black :: Color
  99. black = 2
  100. red :: Color
  101. red = 4
  102. green :: Color
  103. green = 6
  104. darkblue :: Color
  105. darkblue = 8
  106. lightblue :: Color
  107. lightblue = 10
  108. yellow :: Color
  109. yellow = 12
  110. brown :: Color
  111. brown = 14
  112.  
  113. colorName :: Color -> String
  114. colorName 1 = "white"
  115. colorName 2 = "black"
  116. colorName 4 = "red"
  117. colorName 6 = "green"
  118. colorName 8 = "blue"
  119. colorName 10 = "lightblue"
  120. colorName 12 = "yellow"
  121. colorName 14 = "brown"
  122.  
  123. allColors :: [Color]
  124. allColors = [1,2,4,6,8,10,12,14]
  125.  
  126.  
  127.  
  128.  
  129.  
  130.