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

no edit summary
No edit summary
Line 1:
{{task|Raster graphics operations}}
 
Using the data storage type defined [[Basic_bitmap_storage|on this page]] for raster images, and the <codett>draw_line</codett> function defined in [[Bresenham's_line_algorithm|this other one]], draw a '''cubic bezier curves'''
([http://en.wikipedia.org/wiki/Bezier_curves#Cubic_B.C3.A9zier_curves definition on Wikipedia]).
 
 
=={{header|Ada}}==
<lang ada>
procedure Cubic_Bezier
( Picture : in out Image;
Line 31:
end loop;
end Cubic_Bezier;
</adalang>
The following test
<lang ada>
X : Image (1..16, 1..16);
begin
Line 39:
Cubic_Bezier (X, (16, 1), (1, 4), (3, 16), (15, 11), Black);
Print (X);
</adalang>
should produce output:
<pre>
Line 118:
=={{header|OCaml}}==
 
<lang ocaml>let cubic_bezier ~img ~color
~p1:(_x1, _y1)
~p2:(_x2, _y2)
Line 167:
in
by_pair pts (fun p0 p1 -> line ~p0 ~p1);
;;</ocamllang>