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

  1.   >MkAnnulus
  2.      auxillary library file for "MakeSpGen"
  3.      creates "rotating buckets"
  4.  *********************************************************************
  5.         These are constants
  6. _Define_Constants
  7.     I  Usage$ = "[-RMin <r>] [-NSpoke <n>] [-In <rrGGbb>] [-Out <rrGGbb>]"
  8. %  Param$ = "RMin,NSpoke/e,In,Out"
  9. ;  RMin     = 0.6                :
  10.   (0, 1) Inner radius
  11. <  NSpoke   = 5                  :
  12.   non-negative integer
  13. .  In$      = "FFdd33"           :
  14.   rrGGbb
  15. .  Out$     = "337711"           :
  16.   rrGGbb
  17.  In%(2), Out%(2), C%(2)
  18.  *********************************************************************
  19. "        Parse the command line
  20. _Params(b%)
  21. getr(RMin,   b%!0)
  22. geti(NSpoke, b%!4)
  23. getz(In$,    b%!8)
  24. getz(Out$,   b%!12)
  25. _Colour(In$, In%())
  26. _Colour(Out$, Out%())
  27. _Colour(c$, 
  28.  c%())
  29. , "Bad Colours parameter ("+ 
  30. report+ ")"
  31. (c$)<>6 
  32.  1, "format of colour is rrGGbb"
  33.   c% = 
  34. eval("&"+ c$)
  35. %!  c%(0) = (c% 
  36.  &0000FF) >> 0
  37. &!  c%(1) = (c% 
  38.  &00FF00) >> 8
  39. '"  c%(2) = (c% 
  40.  &FF0000) >> 12
  41.  *********************************************************************
  42. +!        The mode has been set
  43. _Define_Palette
  44.  19, &0, 16, &00, &00, &00  :
  45.  palette
  46.  19, &1, 16, &00, &ff, &00
  47.  19, &2, 16, &ee, &00, &00
  48.  19, &3, 16, &ff, &bb, &44
  49.  19, &4, 16, &ee, &ee, &00
  50.  19, &5, 16, &bb, &88, &55
  51.  19, &6, 16, &aa, &44, &bb
  52.  19, &7, 16, &44, &ff, &00
  53.  19, &8, 16, &66, &dd, &ff
  54.  19, &9, 16, &44, &33, &bb
  55.  19, &a, 16, &77, &77, &77
  56.  19, &b, 16, &bb, &ff, &dd
  57.  19, &c, 16, &11, &11, &dd
  58.  19, &d, 16, &ff, &99, &44
  59.  19, &e, 16, &ff, &ff, &ff
  60.  19, &f, 16, &ee, &ee, &ee
  61.  *********************************************************************
  62.      f = (0, 1]
  63. B.        xc, yc = OS co-ordinates of center
  64. _Draw_Frame(f, xc, yc)
  65.  f2, OuterR, InnerR, InnerRR, OuterRR, x, y, t, dx, dy
  66.  spoke%
  67.   f2 = 
  68. (f - 1/2) * 2
  69. H$  OuterR = RMax * (1 - (f2 / 2))
  70.   InnerR = OuterR * RMin
  71.   InnerRR = InnerR * InnerR
  72.   OuterRR = OuterR * OuterR
  73.  x= -OuterR-HalfX 
  74.  OuterR 
  75. M'    
  76.  y= -OuterR-HalfY 
  77.  OuterR 
  78.       t = x*x+y*y
  79. O%      
  80.  t>=InnerRR 
  81.  t<=OuterRR 
  82. P%        
  83.  t-InnerRR < OuterRR-t 
  84.           t = 
  85. (t) - InnerR
  86.         
  87.           t = OuterR - 
  88.         
  89. U+        t = t / ((OuterR - InnerR) / 2)
  90. V5        C%(0) = (Out%(0)-In%(0))*t + 0.5 + In%(0)
  91. W5        C%(1) = (Out%(1)-In%(1))*t + 0.5 + In%(1)
  92. X5        C%(2) = (Out%(2)-In%(2))*t + 0.5 + In%(2)
  93. Y=        p% = (C%(0) << 24) + (C%(1) << 16) + (C%(2) << 8)
  94. Z3        
  95.  "ColourTrans_SetGCOL", p%,,, &100, 0
  96. [-        
  97.  &45, xc + x + 0.5, y + yc + 0.5
  98.       
  99. _0  InnerR = RMax * (RMin + ((1 - RMin) * f2))
  100.  NSpoke 
  101.  spoke%= 1 
  102.  NSpoke
  103.       
  104.  0, spoke% * 2
  105. c4      x = xc + InnerR*
  106. *(f + spoke%/NSpoke))
  107. d4      y = yc + InnerR*
  108. *(f + spoke%/NSpoke))
  109.       
  110.  dx= -X 
  111.  HalfX
  112. f!        
  113.  dy= -Y 
  114.  HalfY
  115. g#          
  116.  xc + 0.5 , yc + 0.5
  117. h*          
  118.  x + dx + 0.5, y + dy + 0.5
  119.         
  120.       
  121.  spoke%
  122.