AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
closepath () typedict.Path
 
Closes the current subpath in this path, if there is one, by implicitly adding a line segment from the current point to the starting point of the subpath. The endpoint of that line segment becomes the new current point and the starting point of the next subpath. closepath does not complain if the current path is empty or already closed.
 
 Example:   The program,
import yoix.stdio.*;

Path p;

moveto(x, y) = printf(" moveto(%.1f, %.1f);\n", x, y);
lineto(x, y) = printf(" lineto(%.1f, %.1f);\n", x, y);
closepath() = printf(" closepath();\n");

p.moveto(100, 100);
p.rlineto(100, 0);
p.closepath();
p.closepath();
p.rlineto(0, 100);
p.closepath();

printf("Output before CTM change:\n");
p.pathforall(moveto, lineto, NULL, NULL, closepath);
p.CTM.scale(2, 2);
printf("\nOutput after CTM change:\n");
p.pathforall(moveto, lineto, NULL, NULL, closepath);
prints something like
Output before CTM change:
 moveto(100.0, 100.0);
 lineto(200.0, 100.0);
 closepath();
 lineto(100.0, 200.0);
 closepath();

Output after CTM change:
 moveto(50.0, 50.0);
 lineto(100.0, 50.0);
 closepath();
 lineto(50.0, 100.0);
 closepath();
on standard output. Notice how the coordinates changed after we scaled the CTM associated with the path, and pay attention to where the second line segment started and the fact that the unnecessary closepath disappeared.
 
 Return:   Path
 
 See Also:   arc, arcn, currentpath, currentpoint, curveto, flattenpath, Graphics, lineto, moveto, newpath, pathbbox, pathforall, quadto, rcurveto, rlineto, rmoveto, rquadto

 

Yoix is a registered trademark of AT&T Inc.