Bitmap/Bézier curves/Cubic: Difference between revisions

m
Fix redim array error when run more than once
(Added Commodore BASIC solution)
m (Fix redim array error when run more than once)
Line 255:
100 bp(0,0)=1:bp(1,0)=70:bp(2,0)=1
110 bp(0,1)=1:bp(1,1)=8:bp(2,1)=23
120 dim pt%(ns,2) : rem individual lines in curve
120 gosub 3000
130 endgosub 3000
140 end
1000 rem plot line
1010 se=0 : rem 0 = steep 1 = !steep
Line 282 ⟶ 283:
2060 return
3000 rem bezier curve
3010 dimfor i=0 to pt%(ns,2)
3020 for it=0 to i/ns
3030 tt1=i/ns1.0-t
3040 t1a=1.0-tt1^2
3050 ab=t1^2.0*t*t1
3060 bc=2.0*t*t1^2
30903070 pt(i,10)=a*bp(0,10)+b*bp(1,10)+c*bp(2,10)
3070 c=t^2
3080 pt(i,01)=a*bp(0,01)+b*bp(1,01)+c*bp(2,01)
3090 next i
3090 pt(i,1)=a*bp(0,1)+b*bp(1,1)+c*bp(2,1)
3100 nextfor i=0 to ns-1
3110 for ix0=int(pt(i,0 to ns-1))
3120 x0y0=int(pt(i,01))
3130 y0x1=int(pt(i,+1,0))
3140 x1y1=int(pt(i+1,01))
3150 y1=int(pt(i+1,1))gosub 1000
3160 gosubnext 1000i
3170 next ireturn
3180 return
</lang>
[https://www.worldofchris.com/assets/c64-bezier-curve.png Screenshot of Bézier curve on C64]
 
 
=={{header|D}}==