JaMImagerDoc.tioga
Tim Diebert: February 24, 1986 10:56:17 am PST
Michael Plass, March 13, 1986 3:42:24 pm PST
Rick Beach, January 18, 1986 12:05:14 pm PST
JaM Imager
CEDAR 6.0 — FOR INTERNAL XEROX USE ONLY
JaM Imager
Tim Diebert
© Copyright 1985 Xerox Corporation. All rights reserved.
Abstract: This document describes the current set of JaMImager primitives implemented by the JaMImagerPackage. It is assumed that the reader is familiar with the JaM language.
Created by: Tim Diebert & friends
Maintained by: Tim Diebert <Diebert.pa>
Keywords: JaM, Imager
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
1. Commands from the Package
Notation
op <arg1> <arg2> b <> õ Description.
means the command op takes the two arguments <arg1> <arg2> from the stack, and replaces them with (in this case) nothing. <arg2> is nearest the top of the stack.
<VEC> is a pair of real numbers on the stack, <x> <y>
<RECTANGLE> is four reals, <x> <y> <w> <h>
<BODY> is executable JaM code, i.e., {1 2 3 4 .maskrectangle} .cvx
Commands implemented by JaMImagerImpl
.dosave <BODY> b <> õ Execute <BODY> under a DoSave imager op.
.dosaveall <BODY> b <> õ Execute <BODY> under a DoSaveAll imager op.
.dround <VEC> b <VEC> õ Performs ImagerTransformation.DRound.
.maket <a> <b> <c> <d> <e> <f> b <ImagerTransformation.Transformation> õ Performs ImagerTransformation.Create
.opent <ImagerTransformation.Transformation> b <a> <b> <c> <d> <e> <f> õ Performs ImagerTransformation.Open
.translate <VEC> b <ImagerTransformation.Transformation> õ Performs ImagerTransformation.Translate
.rotate <r> b <ImagerTransformation.Transformation> õ Performs ImagerTransformation.Rotate
.scale <r> b <ImagerTransformation.Transformation> õ Performs ImagerTransformation.Scale
.scale2 <x> <y> b <ImagerTransformation.Transformation> õ Performs ImagerTransformation.Scale2
.concat <ImagerTransformation.Transformation 1> <ImagerTransformation.Transformation 2> b <ImagerTransformation.Transformation> õ Performs ImagerTransformation.Concat[t2, t1]
.invert <ImagerTransformation.Transformation> b <ImagerTransformation.Transformation> õ Performs ImagerTransformation.Invert
.transform <VEC> <ImagerTransformation.Transformation> b <VEC> õ Performs ImagerTransformation.Transform[t, vec]
.transformvec <VEC> <ImagerTransformation.Transformation> b <VEC> õ Performs ImagerTransformation.TransformVec[t, vec]
.roundxy <VEC> <ImagerTransformation.Transformation> b <VEC> õ Performs ImagerTransformation.RoundXY
.roundxyvec <VEC> <ImagerTransformation.Transformation> b <VEC> õ Performs ImagerTransformation.RoundXYVec
.concatt <ImagerTransformation.Transformation> b <> õ Performs Imager.ConcatT
.scalet <r> b <> õ Performs Imager.ScaleT
.scale2t <VEC> b <> õ Performs Imager.Scale2T
.rotatet <r> b <> õ Performs Imager.RotateT
.translatet <VEC> b <> õ Performs Imager.TranslateT
.moveõ Performs Imager.Move
.transõ Performs Imager.Trans
.setxy <VEC> b <> õ Performs Imager.SetXY
.setxyrel <VEC> b <> õ Performs Imager.SetXYRel
.setxrel <x> b <> õ Performs Imager.SetXRel
.setyrel <y> b <> õ Performs Imager.SetYRel
.getcp <> b <VEC> õ Performs ImagerBackdoor.GetCP (rounded FALSE)
.getcprounded <> b <VEC> õ Performs ImagerBackdoor.GetCP (rounded TRUE)
.findfont <(fontname)> b <ImagerFont.Font> õ Performs ImagerFont.Find
.modifyfont <ImagerFont.Font> <ImagerTransformation.Transformation> b <ImagerFont.Font> õ Performs ImagerFont.Modify
.scalefont <ImagerFont.Font> <s> b <ImagerFont.Font> õ Performs ImagerFont.Scale
.setfont <ImagerFont.Font> b <> õ Performs Imager.SetFont
.fontbox <> b <ImagerFont.Extents> õ ImagerFont.ImagerFont.FontBoundingBox of the current font
.textbox <(rope)> b <ImagerFont.Extents> õ ImagerFont.RopeBoundingBox of the current font
.setamplifyspace <r> b <> õ Performs Imager.SetAmplifySpace
.showrope <(rope)> b <> õ Performs Imager.ShowRope
.showxchar <set> <code> b <> õ Performs Imager.ShowXChar
.startunderlineõ Performs Imager.StartUnderline
.maskunderline <dy> <h> b <> õ Performs Imager.MaskUnderline
.correctmaskõ Performs Imager.CorrectMask
.correctspace <VEC> b <> õ Performs Imager.CorrectSpace
.space <r> b <> õ Performs Imager.Space
.amplifiedspace <x> b <> õ Imager.Space[context, x*amplifySpace];
.setcorrectmeasure <VEC> b <> õ Imager.SetCorrectMeasure
.setcorrecttolerance <VEC> b <> õ Imager.SetCorrectTolerance
.setcorrectshrink <r> b <> õ Imager.SetCorrectShrink
.correct <executable code> b <> õ Imager.Correct
.dontcorrect <executable code> <saveCP (BOOL)> b <> õ Imager.DontCorrect[context, action, saveCP]
.setcolor <ImagerColor.Color> b <> õ Imager.SetColor
.makegray <r> b <ImagerColor.Color> õ Imager.MakeGray
.setgray <r> b <> õ Imager.SetGray
.graylinearcolormodel <> b <ImagerColorOperator.ColorOperator> õ ImagerColorOperator.GrayLinearColorModel
.rgblinearcolormodel <> b <ImagerColorOperator.ColorOperator> õ ImagerColorOperator.RGBLinearColorModel
.pixelarrayfromais <(name)> b <ImagerPixelArray.PixelArray> õ ImagerPixelArray.FromAIS
.pixelarrayfrom3ais <red> <blue> <green> b <ImagerPixelArray.PixelArray> õ ImagerPixelArray.Join3AIS
.pixelarraybounds <ImagerPixelArray.PixelArray> b <RECTANGLE> õ
.pixelarraysamplesperpixel <ImagerPixelArray.PixelArray> b <samplesperpixel> õ
.pixelarray
.makesampledcolor <ImagerPixelArray.PixelArray> <ImagerTransformation.Transformation> <ImagerColorOperator.ColorOperator> b <ImagerColor.Color> õ ImagerColor.MakeSampledColor
.makesampledblack <clear (BOOL)> <ImagerPixelArray.PixelArray> <ImagerTransformation.Transformation> b <ImagerColor.Color> õ ImagerColor.MakeSampledBlack
.setsampledcolor <ImagerPixelArray.PixelArray> <ImagerTransformation.Transformation> <ImagerColorOperator.ColorOperator> b <> õ ImagerColor.SetSampledColor
.setsampledblack <ImagerPixelArray.PixelArray> <ImagerTransformation.Transformation> <clear (BOOL)> b <> õ ImagerColor.SetSampledBlack
.lastpoint <ImagerPath.Trajectory> b <VEC> õ ImagerPath.LastPoint
.moveto <VEC> b <ImagerPath.Trajectory> õ ImagerPath.MoveTo
.lineto <ImagerPath.Trajectory> <VEC> b <ImagerPath.Trajectory> õ ImagerPath.LineTo
.linetox <ImagerPath.Trajectory> <x> b <ImagerPath.Trajectory> õ ImagerPath.LineToX
.linetoy <ImagerPath.Trajectory> <y> b <ImagerPath.Trajectory> õ ImagerPath.LineToY
.curveto <ImagerPath.Trajectory> <VEC1> <VEC2> <VEC3> b <ImagerPath.Trajectory> õ ImagerPath.CurveTo
.conicto <ImagerPath.Trajectory> <VEC1> <VEC2> <r> b <ImagerPath.Trajectory> õ ImagerPath.ConicTo
.arcto <ImagerPath.Trajectory> <VEC1> <VEC2> b <ImagerPath.Trajectory> õ ImagerPath.ArcTo
.makeoutline <ImagerPath.Trajectoryi> <ImagerPath.Trajectoryi-1> ... <ImagerPath.Trajectorycnt> <cnt (INT)> b <ImagerPath.Outline> õ Creates an outline
.maskfill <ImagerPath.Outline> b <> õ Imager.MaskFillOutline (parity FALSE)
.maskfillparity <ImagerPath.Outline> b <> õ Imager.MaskFillOutline (parity TRUE)
.maskfilltrajectory <ImagerPath.Trajectory> b <> õ Imager.MaskFillTrajectory (parity FALSE)
.maskfilltrajectoryparity <ImagerPath.Trajectory> b <> õ Imager.MaskFillTrajectory (parity TRUE)
.setstrokewidth <r> b <> õ Imager.SetStrokeWidth
.setstrokeend <i> b <> õ Sets stroke end. Defs in JaMImager.jam
.setstrokejoint <i> b <> õ Sets stroke joint. Defs in JaMImager.jam
.maskstroke <ImagerPath.Trajectory> b <> õ Imager.MaskStrokeTrajectory
.maskstrokeclosed <ImagerPath.Trajectory> b <> õ Imager.MaskStrokeTrajectory (closed TRUE)
.maskdashedstroke <ImagerPath.Trajectory> <pattern: ARRAY OF REAL> <offset: REAL> <length: REAL> b <> õ makes a dashed stroke
Makes a dashed stroke along the trajectory. The elements of pattern are used cyclically to specify the arc lengths of the strkes and spaces. The offset allows the dashing to start part of the way into the pattern. The length provides the client's estimate of the arc length, so that the dashes will end in a predictable way; if it is zero, the actual arc length of the trajectory is used.
.maskrectangle <RECTANGLE> b <> õ Imager.MaskRectangle
.maskbox <xmin> <ymin> <xmax> <ymax> b <> õ Imager.MaskBox
.maskvector <VEC1> <VEC2> b <> õ Imager.MaskVector
.maskpixel <ImagerPixelArray.PixelArray> b <> õ Imager.MaskPixel
.setpriorityimportant <BOOL> b <> õ Imager.SetPriorityImportant
.setnoimage <BOOL> b <> õ Imager.SetNoImage
.clipoutline <ImagerPath.Outline> b <> õ Imager.ClipOutline (exclude FALSE)
.excludeoutline <ImagerPath.Outline> b <> õ Imager.ClipOutline (exclude TRUE)
.cliprectangle <RECTANGLE> b <> õ Imager.ClipRectangle (exclude FALSE)
.excluderectangle <RECTANGLE> b <> õ Imager.ClipRectangle (exclude TRUE)
Commands implemented by JaMIColorImpl
.turnoncolor <bits> b <> õ Starts the color display in bits per pixel
.turnoffcolorõ Stops the color display.
.onleft <BOOL> b <> õ If true the display goes on the left
.red <> b <ImagerColor.Color> õ ImagerColor.ColorFromAtom[$Red]
.green <> b <ImagerColor.Color> õ ImagerColor.ColorFromAtom[$Green]
.blue <> b <ImagerColor.Color> õ ImagerColor.ColorFromAtom[$Blue]
.magenta <> b <ImagerColor.Color> õ ImagerColor.ColorFromAtom[$Magenta]
.cyan <> b <ImagerColor.Color> õ ImagerColor.ColorFromAtom[$Cyan]
.yellow <> b <ImagerColor.Color> õ ImagerColor.ColorFromAtom[$Yellow]
.black <> b <ImagerColor.Color> õ ImagerColor.ColorFromAtom[$Black]
.white <> b <ImagerColor.Color> õ ImagerColor.ColorFromAtom[$White]
.gray <> b <ImagerColor.Color> õ 50% gray
.icolor <r> b <ImagerColor.Color> õ r% gray
.rgbcolor <r> <g> <b> b <ImagerColor.Color> õ ImagerColor.ColorFromRGB
.hsvcolor <h> <s> <v> b <ImagerColor.Color> õ HSV Color
.hslcolor <h> <s> <l> b <ImagerColor.Color> õ HSL Color
.hsvfromcolor <ImagerColor.Color> b <h> <s> <v> õ HSV from Color
.rgbfromcolor <ImagerColor.Color> b <r> <g> <b> õ RGB from Color
.hslfromcolor <ImagerColor.Color> b <h> <s> <l> õ HSL from Color
.rgbforvtec <r> <g> <b> b <r> <g> <b> õ See the code.
.blackcursorõ Sets black cursor
.whitecursorõ Sets white cursor
Commands implemented by JaMIVector2Impl
.v2add <VEC1> <VEC2> b <VEC> õ Vector2.Add
.v2sub <VEC1> <VEC2> b <VEC> õ Vector2.Sub
.v2neg <VEC> b <VEC> õ Vector2.Neg
.v2mul <r> <VEC> b <VEC> õ Vector2.Mul
.v2div <r> <VEC> b <VEC> õ Vector2.Dev
.v2mulc <VEC1> <VEC2> b <VEC> õ Vector2.MulC
.v2divc <VEC1> <VEC2> b <VEC> õ Vector2.DivC
.v2dot <VEC1> <VEC2> b <VEC> õ Vector2.Dot
.v2cross <VEC1> <VEC2> b <VEC> õ Vector2.Cross
.v2square <VEC> b <r> õ Vector2.Square
.v2length <VEC> b <r> õ Vector2.Length
.v2unit <VEC> b <VEC> õ Vector2.Unit
.v2exch <VEC1> <VEC2> b <VEC2> <VEC1> õ Exchange the top vectors
Commands implemented by JaMIInterpressImpl
.writeinterpress (ip file name) [ <dcl0> <dcl1> . . . ] <BODY> b <>
Makes an Interpress master by executing <BODY>. The items in square braces are things to put in the preamble, i.e., fonts and pixelarrays. When <BODY> is executed, the page number is on the top of the stack; it should leave a value on the stack that is nonzero (e.g, .true) if it is the last page of the document, or zero (.false) if it wishes to do more pages; note that if <BODY> leaves that stack as it finds it, a one-page master will be created.
Example:
(Roman10) (Xerox/Pressfonts/TimesRoman-mrr) .findfont 10 .scalefont .def
(monkPixelArray) ([cyan]<AIS>monk.ais) .pixelarrayfromais .def
(foo) {
monkPixelArray .drawpa
1 .setgray 10 10 .setxy Roman10 .setfont
"Monk" .showrope
}.cvx .def
(print){(Foo.ip) [ Roman10 monkPixelArray ] {foo}.cvx .writeinterpress}.cvx .def
Multi-page example:
(bigfont) (xerox/pressfonts/timesroman-bir) .findfont 800 .scale .modifyfont .def
(count.ip) [ bigfont ] {
.dup = % Print the page number
bigfont .setfont% a one-char-per-page size font
72 72 .setxy% position for start of text
.dup .cvs% get page number as rope, but leave original on stack for later
.showrope% Show the big number
9 .eq% quit if this was page 9 (would like to say 9 .ge)
}.cvx .writeinterpress
.writeinterpresspages (ip file name) [ <dcl0> <dcl1> . . . ] [ <b0> <b1> . . . ] b <>
Makes an Interpress master by executing <b0> <b1> . . ., each for a separate page.
Implemented in JaMImager.JaM using .writeinterpress
Example:
(bigfont) (xerox/pressfonts/timesroman-bir) .findfont 700 .scale .modifyfont .def
(sho) {bigfont .setfont 0 72 .setxy .showrope} .cvx .def
(biglet.ip) [ bigfont ] [ {(B) sho} {(I) sho} {(G) sho} ] .writeinterpresspages
.makeinterpress <BODY> <(ip file name)> b <> õ For compatibility
2. Eamples and hints
The following examples use "sugar" defined in JaMImager.JaM
Gray scale and Color images
(mandrillPixelArray)
([cyan]<AIS>Baboon-red.ais) ([cyan]<AIS>Baboon-green.ais) ([cyan]<AIS>Baboon-blue.ais) .pixelarrayfrom3ais
.def
This makes a pixel array from the three named files, and saves it under the name "mandrillPixelArray". Note the lack of any brackets around part before the .def. You want to do this once, since it will allow the imager to work better if you use the same pixelarray each time, rather than going back out to the files. Making a pixel array does not require the whole AIS file to be read, so this is a relatively cheap operation, once the files are on your disk.
(monkPixelArray) ([cyan]<AIS>monk.ais) .pixelarrayfromais .def
This is a black-and-white image.
mandrillPixelArray .drawpa
draws one instance of the pixelarray, guessing that it is a color image from the fact that there are 3 samples per pixel. The first time you use a pixelarray as a color on a given device, there will be a pause while the image is read in and put into the right format for that device. Subsequent uses will be faster.
mandrillPixelArray .setpacolor .printtouch .printtouch .drawbox
Takes two mouse clicks (printing the coordinates for later use) and fills their bounding box with mandrills.
Paths as arrays of trajectories
.red .setcolor .printtouch .printmoveto {.printtouch .printlineto .dup .maskstroke}.cvx .loop
This is a way to capture a polygon from a series of mouse clicks. Note the feedback is done in an inefficient way, drawing the whole stroke each time, but people can't click very fast anyway. Click "Interrupt" to stop.
(monkoutline) [
145.0 0.0 .moveto 145.0 17.5 .lineto 137.5 32.5 .lineto 142.5 57.5 .lineto 152.5 70.0 .lineto 135.0 70.0 .lineto 117.5 30.0 .lineto 97.5 25.0 .lineto 80.0 32.5 .lineto 52.5 72.5 .lineto 60.0 122.5 .lineto 22.5 202.5 .lineto 17.5 220.0 .lineto 25.0 235.0 .lineto 27.5 250.0 .lineto 37.5 262.5 .lineto 40.0 275.0 .lineto 40.0 285.0 .lineto 42.5 302.5 .lineto 52.5 312.5 .lineto 57.5 322.5 .lineto 67.5 330.0 .lineto 65.0 350.0 .lineto 62.5 377.5 .lineto 87.5 410.0 .lineto 107.5 432.5 .lineto 117.5 457.5 .lineto 147.5 492.5 .lineto 187.5 527.5 .lineto 217.5 525.0 .lineto 240.0 540.0 .lineto 252.5 545.0 .lineto 247.5 557.5 .lineto 252.5 565.0 .lineto 262.5 567.5 .lineto 267.5 575.0 .lineto 282.5 575.0 .lineto 275.0 592.5 .lineto 267.5 605.0 .lineto 260.0 612.5 .lineto 255.0 622.5 .lineto 255.0 632.5 .lineto 257.5 640.0 .lineto 257.5 655.0 .lineto 252.5 675.0 .lineto 252.5 692.5 .lineto 257.5 710.0 .lineto 277.5 742.5 .lineto 295.0 757.5 .lineto 312.5 767.5 .lineto 330.0 770.0 .lineto 347.5 775.0 .lineto 372.5 772.5 .lineto 392.5 762.5 .lineto 407.5 755.0 .lineto 422.5 745.0 .lineto 430.0 727.5 .lineto 435.0 702.5 .lineto 437.5 685.0 .lineto 440.0 670.0 .lineto 442.5 650.0 .lineto 442.5 615.0 .lineto 432.5 607.5 .lineto 430.0 585.0 .lineto 445.0 577.5 .lineto 502.5 530.0 .lineto 540.0 522.5 .lineto 587.5 452.5 .lineto 617.5 385.0 .lineto 630.0 345.0 .lineto 650.0 215.0 .lineto 650.0 195.0 .lineto 647.5 175.0 .lineto 635.0 160.0 .lineto 617.5 152.5 .lineto 600.0 125.0 .lineto 605.0 120.0 .lineto 602.5 112.5 .lineto 595.0 115.0 .lineto 590.0 85.0 .lineto 590.0 0.0 .lineto
502.5 632.5 .moveto 545.0 740.0 .lineto 575.0 632.5 .lineto 470.0 710.0 .lineto 602.5 712.5 .lineto
] .def
This makes an array of trajectories and saves it for future use
e monkPixelArray .setpacolor monkoutline .arraymaskfill
This draws the clipped monk
(redoutlinedmonk) {{.red .setcolor roundjoint 20 .setstrokewidth monkoutline .arraymaskstrokeclosed monkPixelArray .setpacolor monkoutline .arraymaskfill}.cvx .dosave}.cvx .def
This draws the clipped monk inside a red outline.
(smallmonk) {{.4 .scalet redoutlinedmonk}.cvx .dosave}.cvx .def
A smaller version.
(monkpersp) {{{.mouse 2 .copy .translatet 480 .exch .sub 480 .div .scalet .pop smallmonk}.cvx .dosave}.cvx .loop}.cvx .def
Just for fun