Advertisement
felixnardella

poligoni-inscr-circoscr.bas

Mar 14th, 2022 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. 5 rem poligoni inscritti e circoscritti by felice nardella (2022)
  2. 10 poke53280,15:s=8192
  3. 15 poke53272,peek(53272)or8:poke53265,peek(53265)or32
  4. 20 gosub320
  5. 25 rem clear color ram
  6. 30 cb$="pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp"
  7. 35 cb$=cb$+cb$:cb$=cb$+left$(cb$,121)
  8. 40 print"{clear}"cb$cb$cb$cb$;:print"ppp";:poke2023,16
  9. 45 tw(0)=1:fori=1to7:tw(i)=tw(i-1)*2:next
  10. 50 fori=1024to2023:pokei,16*13:next
  11. 55 goto225
  12. 58 rem plot x,y
  13. 60 p=s+320*int(y/8)+8*int(x/8)+(yand7)
  14. 65 pokep,peek(p)ortw(7-(xand7))
  15. 70 return
  16. 75 rem calc lines pixels
  17. 80 dx=x1-x2:dy=y1-y2
  18. 85 ifdx=0goto130
  19. 90 m=dy/dx
  20. 95 ab=1:ifm>1orm<-1goto155
  21. 100 ifdx>0thenab=-1
  22. 105 forx=x1tox2stepab
  23. 110 y=m*(x-x1)+y1
  24. 115 gosub60
  25. 120 next:return
  26. 125 rem if dx=0
  27. 130 x=x1:ab=1:ifdy>0thenab=-1
  28. 135 fory=y1toy2stepab
  29. 140 gosub60
  30. 145 next:return
  31. 150 rem if m>1orm<-1
  32. 155 ab=1:ifdy>0thenab=-1
  33. 160 fory=y1toy2stepab
  34. 165 x=(y-y1)/m+x1
  35. 170 gosub60
  36. 175 next:return
  37. 180 rem plot polygons
  38. 185 fi=2*pi/n:s1=sin(fi):c1=cos(fi)
  39. 190 y1=0:x1=r
  40. 195 fork=1ton
  41. 200 x2=xc+x1*c1-y1*s1
  42. 205 y2=yc+x1*s1+y1*c1
  43. 210 x1=xc+x1:y1=yc+y1:gosub80
  44. 215 x1=x2-xc:y1=y2-yc
  45. 220 next:return
  46. 225 rem main
  47. 230 xc=160:yc=100
  48. 235 fori=0to2
  49. 240 r=25*2^i:n=r:gosub185
  50. 245 n=3*2^i:gosub185
  51. 248 ifn=3thenr=r*2:gosub185
  52. 250 ifn=6thenr=r*2/sqr(3):gosub185
  53. 255 ifn=12thenr=r*4/(sqr(6)+sqr(2)):gosub185
  54. 260 poke198,0:wait198,1
  55. 265 gosub320
  56. 270 next
  57. 280 printchr$(147)
  58. 295 rem turn graphics off
  59. 300 poke53265,peek(53265)and(223)
  60. 305 poke53272,21:poke53280,14
  61. 310 end
  62. 315 rem clear graphic ram
  63. 320 cb$=""
  64. 325 p1=peek(51):p2=peek(52)
  65. 330 poke51,64:poke52,63
  66. 335 forcn=1to125:cb$=cb$+chr$(0):next
  67. 340 poke51,p1:poke52,p2
  68. 345 return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement