home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1992-09-28 | 3.7 KB | 150 lines |
- >MkSqrStar
- auxillary library file for "MakeSpGen"
- creates rotating "Star of David"
- "special" star, in that for each element it goes
- under - over - under - over
- but not easy to program!
- *********************************************************************
- These are constants
- _Define_Constants
- ; Usage$ = "[-Delta <radians>] [-Colours <rrGGbb:...>]"
- Param$ = "Delta,Colours"
- Delta = 2*
- 6 Colours$ = "ffFFff:ff22bb:22BBcc:cc1111:00CC66"
- Col%(5)
- v_small = 1E-4
- *********************************************************************
- " Parse the command line
- _Params(b%)
- getr(Delta, b%!0)
- getz(Colours$, b%!4)
- _Read_Colours(Colours$, Col%(), 5)
- *********************************************************************
- ! The mode has been set
- _Define_Palette
- 19, &0, 16, &00, &00, &00 :
- palette
- 19, &1, 16, &00, &ff, &00
- 19, &2, 16, &ee, &00, &00
- 19, &3, 16, &ff, &bb, &44
- 19, &4, 16, &ee, &ee, &00
- 19, &5, 16, &bb, &88, &55
- 19, &6, 16, &aa, &44, &bb
- 19, &7, 16, &44, &ff, &00
- 19, &8, 16, &66, &dd, &ff
- 19, &9, 16, &44, &33, &bb
- 19, &a, 16, &77, &77, &77
- 19, &b, 16, &bb, &ff, &dd
- 19, &c, 16, &11, &11, &dd
- 19, &d, 16, &ff, &99, &44
- 19, &e, 16, &ff, &ff, &ff
- 19, &f, 16, &ee, &ee, &ee
- *********************************************************************
- f = (0, 1]
- 7. xc, yc = OS co-ordinates of center
- _Draw_Frame(f, xc, yc)
- i, start, end, Radius
- p(4, 1)
- Radius = RMax - 8
- i= 0
- ?. p(i, 0) = xc + Radius *
- *(f+i/5))
- @. p(i, 1) = xc + Radius *
- *(f+i/5))
- line, f
- start = line
- end = (start + 3)
- H!
- line>=5
- start, end
- I'
- _line(start, end, f, line
- line, f
- _line(0, 2, 0.2, 2) :
- final fiddle
- 0, 1.0
- 1, 1.0
- 2, 1.0
- 0, 0.2
- 3, 1.0
- 5+1, 0.2
- 4, 1.0
- 5+0, 0.5
- 5+1, 0.2
- 0, 0
- _line(start, end, f, line)
- x1, y1, x2, y2
- x1 = p(start, 0)
- y1 = p(start, 1)
- x2 = p(end, 0)
- y2 = p(end, 1)
- "ColourTrans_SetGCOL", Col%(line),,, &100, 0
- line(x1, y1, x1 + (x2-x1)*f, y1 + (y2-y1)*f)
- line(x1, y1, x2, y2)
- dx, dy, x, y, a, i, n%
- f& a =
- bearing(x1,y1, x2,y2) +
- dx = x2 - x1
- dy = y2 - y1
- (dx)>
- (dy)
- n% =
- (dx)/X + 0.5
- n% =
- (dy)/Y + 0.5
- y = dy/n%
- x = dx/n%
- i= 0
- q*
- x1+i*x+0.5, y1+i*y+0.5, X, Y
- x2+0.5, y2+0.5, X, Y
- 0 <= returns < 2*PI = angle to get to p2 from p1
- complicated because ATN() is inaccurate at y/x large
- and ATN() only returns values for first quadrant
- bearing(x1,y1, x2,y2)
- a, x, y, mx, my
- x = x2-x1
- y = y2-y1
- mx =
- my =
- my<v_small
- x<=0
- * a =
- :
- west
-
- + a = 0 :
- east
-
- mx>my
- a =
- (my/mx)
-
- a =
- /2 -
- (mx/my)
-
- 1 :
- here 0<=a<PI/2 :REM north-east
- % :
- now see which quadrant in
- x>=0
-
- y<0
- 0 a = 2*
- - a :
- south-east
-
-
-
- y<0
- 0 a =
- +a :
- south-west
-
- 0 a =
- -a :
- north-west
-
-
-