home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / spritegen / MkSqrStar (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1992-09-28  |  3.7 KB  |  150 lines

  1.   >MkSqrStar
  2.      auxillary library file for "MakeSpGen"
  3.      creates rotating "Star of David"
  4.      "special" star, in that for each element it goes
  5.              under - over - under - over
  6.      but not easy to program!
  7.  *********************************************************************
  8.         These are constants
  9. _Define_Constants
  10. ;  Usage$ = "[-Delta <radians>] [-Colours <rrGGbb:...>]"
  11.   Param$ = "Delta,Colours"
  12.   Delta     = 2*
  13. 6  Colours$  = "ffFFff:ff22bb:22BBcc:cc1111:00CC66"
  14.  Col%(5)
  15.   v_small = 1E-4
  16.  *********************************************************************
  17. "        Parse the command line
  18. _Params(b%)
  19. getr(Delta,    b%!0)
  20. getz(Colours$, b%!4)
  21. _Read_Colours(Colours$, Col%(), 5)
  22.  *********************************************************************
  23.  !        The mode has been set
  24. _Define_Palette
  25.  19, &0, 16, &00, &00, &00  :
  26.  palette
  27.  19, &1, 16, &00, &ff, &00
  28.  19, &2, 16, &ee, &00, &00
  29.  19, &3, 16, &ff, &bb, &44
  30.  19, &4, 16, &ee, &ee, &00
  31.  19, &5, 16, &bb, &88, &55
  32.  19, &6, 16, &aa, &44, &bb
  33.  19, &7, 16, &44, &ff, &00
  34.  19, &8, 16, &66, &dd, &ff
  35.  19, &9, 16, &44, &33, &bb
  36.  19, &a, 16, &77, &77, &77
  37.  19, &b, 16, &bb, &ff, &dd
  38.  19, &c, 16, &11, &11, &dd
  39.  19, &d, 16, &ff, &99, &44
  40.  19, &e, 16, &ff, &ff, &ff
  41.  19, &f, 16, &ee, &ee, &ee
  42.  *********************************************************************
  43.      f = (0, 1]
  44. 7.        xc, yc = OS co-ordinates of center
  45. _Draw_Frame(f, xc, yc)
  46.  i, start, end, Radius
  47.  p(4, 1)
  48.   Radius = RMax - 8
  49.  i= 0 
  50. ?.    p(i, 0) = xc + Radius * 
  51. *(f+i/5))
  52. @.    p(i, 1) = xc + Radius * 
  53. *(f+i/5))
  54.  line, f
  55.     start = line 
  56.     end   = (start + 3) 
  57. H!    
  58.  line>=5 
  59.  start, end
  60. I'    
  61. _line(start, end, f, line 
  62.  line, f
  63. _line(0, 2, 0.2, 2)  :
  64.  final fiddle
  65.    0, 1.0
  66.    1, 1.0
  67.    2, 1.0
  68.    0, 0.2
  69.    3, 1.0
  70.  5+1, 0.2
  71.    4, 1.0
  72.  5+0, 0.5
  73.  5+1, 0.2
  74.    0, 0
  75. _line(start, end, f, line)
  76.  x1, y1, x2, y2
  77.   x1 = p(start, 0)
  78.   y1 = p(start, 1)
  79.   x2 = p(end, 0)
  80.   y2 = p(end, 1)
  81.  "ColourTrans_SetGCOL", Col%(line),,, &100, 0
  82. line(x1, y1, x1 + (x2-x1)*f, y1 + (y2-y1)*f)
  83. line(x1, y1, x2, y2)
  84.  dx, dy, x, y, a, i, n%
  85. f&  a = 
  86. bearing(x1,y1, x2,y2) + 
  87.   dx = x2 - x1
  88.   dy = y2 - y1
  89. (dx)>
  90. (dy) 
  91.     n% = 
  92. (dx)/X + 0.5
  93.     n% = 
  94. (dy)/Y + 0.5
  95.   y = dy/n%
  96.   x = dx/n%
  97.  i= 0 
  98. q*    
  99.  x1+i*x+0.5, y1+i*y+0.5, X, Y
  100.  x2+0.5, y2+0.5, X, Y
  101.   0 <= returns < 2*PI = angle to get to p2 from p1
  102.  complicated because ATN() is inaccurate at y/x large
  103.  and ATN() only returns values for first quadrant
  104. bearing(x1,y1, x2,y2)
  105.  a, x, y, mx, my
  106.   x = x2-x1
  107.   y = y2-y1
  108.   mx = 
  109.   my = 
  110.  my<v_small 
  111.  x<=0 
  112. *      a = 
  113.                     :
  114.  west
  115.         
  116. +      a = 0                     :
  117.  east
  118.         
  119.  mx>my 
  120.       a = 
  121. (my/mx)
  122.         
  123.       a = 
  124. /2 - 
  125. (mx/my)
  126.         
  127. 1    :
  128.   here 0<=a<PI/2        :REM north-east
  129. %    :
  130.   now see which quadrant in
  131.  x>=0 
  132.       
  133.  y<0 
  134. 0        a = 2*
  135.  - a            :
  136.  south-east
  137.       
  138.         
  139.       
  140.  y<0 
  141. 0        a = 
  142. +a                :
  143.  south-west
  144.       
  145. 0        a = 
  146. -a                :
  147.  north-west
  148.       
  149.         
  150.