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

m
→‎[[Cubic_bezier_curves#ALGOL 68]]: virtualise procedure and add flag for test
m (→‎[[Cubic_bezier_curves#ALGOL 68]]: introduce rounding as per Ada)
m (→‎[[Cubic_bezier_curves#ALGOL 68]]: virtualise procedure and add flag for test)
Line 66:
<!-- {{does not work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386 - '''pragmat''' '''read''' is not part of algol68rs}} -->
<lang algol>PRAGMAT READ "Bresenhams_line_algorithm.a68" PRAGMAT;
 
PROC cubic bezier OF class image :=
( REF IMAGE picture,
POINT p1, p2, p3, p4,
Line 75:
BEGIN
INT n = (in n|(INT n):n|20); # default 20 #
[0:n]POINT points;
FOR i FROM LWB points TO UPB points DO
REAL t = i / n,
Line 86:
OD;
FOR i FROM LWB points TO UPB points - 1 DO
(line OF class image)(picture, points (i), points (i + 1), color)
OD
END # cubic bezier #;
 
#
The following test
#
IF test THEN
BEGIN
REF IMAGE x = INIT LOC[16,16]PIXEL;
(fill OF class image)(x, (white OF class image));
(cubic bezier OF class image)(x, (16, 1), (1, 4), (3, 16), (15, 11), (black OF class image), EMPTY);
(print OF class image) (x)
ENDFI</lang>
Output:
<pre>