AT&T Home | AT&T Labs | Research

# The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
setmatrix (Matrix mtx) typedict.Matrix

Replaces this matrix with a copy of mtx and returns this matrix to the caller.

currentmatrix and setmatrix are sometimes used in pairs when an application describes a path in a coordinate system that has been scaled or sheared, but wants to stroke the outline of that path in a way that hides the changes that were made to the coordinate system.

Incidentally, one very common use of currentmatrix and setmatrix in PostScript, namely drawing the outline of an ellipse, can usually be handled more efficiently by passing horizontal and vertical scaling arguments directly to the arc drawing built-ins defined in Graphics and Path.
 Example: The program, import yoix.*.*; JFrame f = { Graphics graphics = { Color foreground = Color.blue; int linewidth = 72/8; int linecap = yoix.graphics.CAP_ROUND; }; paint(Rectangle rect) { Matrix mtx; int n; graphics { // "named block" gsave(); translate(size.width/2, size.height/2); mtx = currentmatrix(); scale(2, .5); for (n = 0; n < 12; n++) { moveto(0, 0); rlineto(1.5*72, 0); rotate(30); } setmatrix(mtx); stroke(); grestore(); } } }; f.visible = TRUE; defines a paint function in a frame that draws 1.5 inch line segments marking every 30 degrees (in user space) at the center of the frame. The coordinate system is stretched horizontally and squashed vertically, so line lengths and angles look strange, but we carefully used currentmatrix and setmatrix, so line widths all look about right. Return: Matrix See Also: concat, concatmatrix, currentmatrix, dividematrix, dtransform, Graphics, identmatrix, idtransform, initmatrix, invertmatrix, itransform, maptopixel, rotate, scale, shear, transform, translate

Yoix is a registered trademark of AT&T Inc.