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

Content deleted Content added
Updated D entry
Added zkl
Line 730:
SetVid(3); \restore normal text display
]</lang>
 
=={{header|zkl}}==
Uses the PPM class from http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#zkl
 
Add this to the PPM class:
<lang zkl> fcn qBezier(p0x,p0y, p1x,p1y, p2x,p2y, rgb, numPts=500){
numPts.pump(Void,'wrap(t){ // B(t)
t=t.toFloat()/numPts; t1:=(1.0 - t);
a:=t1*t1; b:=t*t1*2; c:=t*t;
x:=a*p0x + b*p1x + c*p2x + 0.5;
y:=a*p0y + b*p1y + c*p2y + 0.5;
__sSet(rgb,x,y);
});
}</lang>
Doesn't use line segments, they don't seem like an improvement.
<lang zkl>bitmap:=PPM(300,300,0xff|ff|ff);
bitmap.qBezier(10,200, 250,30, 150,280, 0);
bitmap.write(File("foo.ppm","wb"));</lang>
{{out}}
Same as the BBC BASIC image:[[Image:bezierquad_bbc.gif]]
 
{{omit from|GUISS}}