rrutherford

DrawCircle.bas

Jun 21st, 2020
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 10 RUN AT 3: LAYER CLEAR : LAYER 2,1: BORDER 0: PAPER 0: CLS
  2. 20 REPEAT
  3. 30 INK % RND 255
  4. 40 PROC DrawCircle(% RND 250,% RND 190,% RND 20+5,1,0)
  5. 50 ;INK % RND 255
  6. 60 ;PROC DrawRect(% RND 250,% RND 170,% RND 50+5,% RND 50+5,0)
  7. 70 REPEAT UNTIL 0
  8. 80 GO TO %9999
  9. 90:
  10. 100 DEFPROC DrawRect(%x,%y,%w,%h,fill)
  11. 110 IF % SGN {(w <= 0) OR (h <= 0)} THEN ENDPROC
  12. 120 IF NOT fill THEN PLOT % SGN {x},% SGN {y}: DRAW %w-1,0: DRAW 0,%h-1: DRAW % SGN {-w+1},0: DRAW 0,% SGN {-h+1}: ENDPROC
  13. 130 IF % SGN {x < 0} THEN %w=%w- ABS x:%x=0
  14. 140 IF % SGN {y < 0} THEN %h=%h- ABS y:%y=0
  15. 150 IF %(x+w) >= 254 THEN %w=%255-x+1
  16. 160 IF %(y+h) >= 190 THEN %h=%191-y+1
  17. 170 LAYER ERASE %x,%y,% SGN {w},% SGN {h},% PEEK $5B60
  18. 180 ENDPROC
  19. 190:
  20. 200 DEFPROC DrawCircle(%x,%y,%r,fill,fast)
  21. 210 RUN AT 3: LOCAL %c,%i,%m,%q,r,ra,%s,%u,%v
  22. 220 r=%r:r=r*1.414:%s=r:%q=% INT {r}/2:%m=0
  23. 230 IF % SGN {(x-r <= 0) OR (y-r <= 0) OR (x+r > 254) OR (y+r > 191)} THEN %m=1
  24. 240 CIRCLE %x,%y,%r
  25. 250 IF % INT { NOT fill} OR (r<1) OR SGN {(x < 0) OR (y < 0)} THEN ENDPROC
  26. 260 IF NOT fast THEN %i=%r: REPEAT : CIRCLE %x,%y,%i:%i=%i-1: REPEAT UNTIL %i <= (s/2-1): PROC DrawRect(% SGN {x}-q,% SGN {y}-q,%s,%s,1)
  27. 270 %b=% SGN {-r}:%u=%b:%c=% PEEK $5B60
  28. 280 REPEAT
  29. 290 ra=%r*r:b=%b*b:%a=- SQR (ra-b)
  30. 300 IF % NOT m THEN %f=% ABS a*2: LAYER ERASE %x+a,%y+b,%f+1,%1,%c: LAYER ERASE %x+a,%y-b,%f+1,%1,%c: LAYER ERASE %x+u,%y+a,%1,%f+1,%c: LAYER ERASE %x-u,%y+a,%1,%f+1,%c: ELSE %f=% ABS a*2: PLOT %x+a,%y+b: DRAW %f,%0: PLOT %x+a,%y-b: DRAW %f,%0: PLOT %x+u,%y+a: DRAW %0,%f: PLOT %x-u,%y+a: DRAW %0,%f
  31. 310 %b=%b+1:%u=%u+1
  32. 320 REPEAT UNTIL % SGN {b} >= -(q-2)
  33. 330 IF fast THEN PROC DrawRect(% SGN {x}-q,% SGN {y}-q,%s,%s,1)
  34. 340 ENDPROC
RAW Paste Data