Bitmap/Bézier curves/Cubic: Difference between revisions
Content added Content deleted
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: | 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}} --> |
<!-- {{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; |
<lang algol>PRAGMAT READ "Bresenhams_line_algorithm.a68" PRAGMAT; |
||
cubic bezier OF class image := |
|||
( REF IMAGE picture, |
( REF IMAGE picture, |
||
POINT p1, p2, p3, p4, |
POINT p1, p2, p3, p4, |
||
Line 75: | Line 75: | ||
BEGIN |
BEGIN |
||
INT n = (in n|(INT n):n|20); # default 20 # |
INT n = (in n|(INT n):n|20); # default 20 # |
||
[0:n]POINT points; |
[0:n]POINT points; |
||
FOR i FROM LWB points TO UPB points DO |
FOR i FROM LWB points TO UPB points DO |
||
REAL t = i / n, |
REAL t = i / n, |
||
Line 86: | Line 86: | ||
OD; |
OD; |
||
FOR i FROM LWB points TO UPB points - 1 DO |
FOR i FROM LWB points TO UPB points - 1 DO |
||
line (picture, points (i), points (i + 1), color) |
(line OF class image)(picture, points (i), points (i + 1), color) |
||
OD |
OD |
||
END # cubic bezier #; |
END # cubic bezier #; |
||
# |
# |
||
The following test |
The following test |
||
# |
# |
||
IF test THEN |
|||
BEGIN |
|||
REF IMAGE x = INIT LOC[16,16]PIXEL; |
REF IMAGE x = INIT LOC[16,16]PIXEL; |
||
(fill OF class image)(x, (white OF class image)); |
(fill OF class image)(x, (white OF class image)); |
||
cubic bezier (x, (16, 1), (1, 4), (3, 16), (15, 11), (black OF class image), EMPTY); |
(cubic bezier OF class image)(x, (16, 1), (1, 4), (3, 16), (15, 11), (black OF class image), EMPTY); |
||
(print OF class image) (x) |
(print OF class image) (x) |
||
FI</lang> |
|||
Output: |
Output: |
||
<pre> |
<pre> |