--JaM test for GFigToJaM module --Written by M.Stone --Last changed by M.Stone 26-Feb-82 16:20:18 DIRECTORY GriffinFig, ConvertUnsafe USING [ToRope], ReadGriffin, JaMFnsDefs, TJaMGraphics USING [Painter], Graphics USING [Save,Translate,Rotate,Scale,Context], Cubic USING[Bezier], Vector USING[Vec,Sub]; JaMGF2J: PROGRAM IMPORTS JaMFnsDefs, GriffinFig, ReadGriffin, ConvertUnsafe, Graphics, TJaMGraphics, Vector= BEGIN OPEN JaMFnsDefs; GFNewFile: PROC = { s: STRING ← [20]; PopString[s]; GriffinFig.NewFile[ConvertUnsafe.ToRope[s]]; }; GFCloseFile: PROC = { GriffinFig.CloseFile[]; }; GFReadFile: PROC = { s: STRING ← [20]; view: INTEGER ← PopInteger[]; PopString[s]; ReadGriffin.ReadFile[ConvertUnsafe.ToRope[s], (SELECT view FROM 0 => main, 1 => alternate, 3 => both, ENDCASE => main)]; }; GFColor: PROC = { h,s,b,t,id: INTEGER; t ← PopInteger[]; b ← PopInteger[]; s ← PopInteger[]; h ← PopInteger[]; id ← GriffinFig.Color[h,s,b,t]; PushInteger[id]; }; GFFont: PROC = { or: REAL ← GetReal[]; name: STRING ← [20]; id: INTEGER; PopString [name]; id ← GriffinFig.Font[ConvertUnsafe.ToRope[name],or]; PushInteger[id]; }; GFLineStyle: PROC = { w: REAL ← GetReal[]; id,color: INTEGER; color ← PopInteger[]; id ← GriffinFig.LineStyle[color,w]; PushInteger[id]; }; GFFillStyle: PROC = { id,color: INTEGER; color ← PopInteger[]; id ← GriffinFig.FillStyle[color]; PushInteger[id]; }; GFTextStyle: PROC = { id,color,font: INTEGER; font ← PopInteger[]; color ← PopInteger[]; id ← GriffinFig.TextStyle[color,font]; PushInteger[id]; }; GFStartPath: PROC = { GriffinFig.StartPath[]; }; GFEnterPoint: PROC = { p: Vector.Vec ← GetPoint[]; GriffinFig.EnterPoint[p]; }; GFEnterCubic: PROC = { c: Cubic.Bezier; c.b0 ← GetPoint[]; c.b1 ← GetPoint[]; c.b2 ← GetPoint[]; c.b3 ← GetPoint[]; GriffinFig.EnterCubic[c]; }; GFNewBoundary: PROC = { GriffinFig.NewBoundary[]; }; GFEndPath: PROC = { id: INTEGER ← GriffinFig.EndPath[]; PushInteger[id]; }; GFLineObject: PROC = { style,path,id: INTEGER; path ← PopInteger[]; style ← PopInteger[]; id ← GriffinFig.LineObject[style,path]; PushInteger[id]; }; GFAreaObject: PROC = { line,fill,path,id: INTEGER; path ← PopInteger[]; fill ← PopInteger[]; line ← PopInteger[]; id ← GriffinFig.AreaObject[line,fill,path]; PushInteger[id]; }; GFTextObject: PROC = { style,id: INTEGER; s: STRING ← [20]; r: REAL ← GetReal[]; vec: Vector.Vec ← GetPoint[]; anchor: INTEGER ← PopInteger[]; PopString[s]; style ← PopInteger[]; id ← GriffinFig.TextObject[style,ConvertUnsafe.ToRope[s], (SELECT anchor FROM 0 => left, 1 => right, 2 => center, ENDCASE => left), vec,r]; PushInteger[id]; }; GFStartCluster: PROC = { GriffinFig.StartCluster[]; }; GFEnterObject: PROC = { obj: INTEGER ← PopInteger[]; GriffinFig.EnterObject[obj]; }; GFEnterCluster: PROC = { clu: INTEGER ← PopInteger[]; GriffinFig.EnterCluster[clu]; }; GFCluster: PROC = { id: INTEGER ← GriffinFig.Cluster[]; }; GFMove: PROC = { to,from: Vector.Vec; move: PROC[dc: Graphics.Context] = { [] ← Graphics.Save[dc]; to ← Vector.Sub[to,from]; Graphics.Translate[dc,to.x,to.y]}; to ← GetPoint[]; from ← GetPoint[]; TJaMGraphics.Painter[move]; }; GFRotate: PROC = { angle: REAL ← GetReal[]; center: Vector.Vec ← GetPoint[]; rotate: PROC[dc: Graphics.Context] = { [] ← Graphics.Save[dc]; Graphics.Translate[dc,center.x,center.y]; Graphics.Rotate[dc,angle]; Graphics.Translate[dc,-center.x,-center.y]}; TJaMGraphics.Painter[rotate]; }; GFScale: PROC = { sy: REAL ← GetReal[]; sx: REAL ← GetReal[]; center: Vector.Vec ← GetPoint[]; scale: PROC[dc: Graphics.Context] = { [] ← Graphics.Save[dc]; Graphics.Translate[dc,center.x,center.y]; Graphics.Scale[dc,sx,sy]; Graphics.Translate[dc,-center.x,-center.y]}; TJaMGraphics.Painter[scale]; }; GetPoint: PROC RETURNS[p: Vector.Vec] = { p.y ← GetReal[]; p.x ← GetReal[]; }; Register[".gfnew"L,GFNewFile]; Register[".gfclose"L,GFCloseFile]; Register[".gfcolor"L,GFColor]; Register[".gffont"L,GFFont]; Register[".gflinestyle"L,GFLineStyle]; Register[".gffillstyle"L,GFFillStyle]; Register[".gftextstyle"L,GFTextStyle]; Register[".gfstartpath"L,GFStartPath]; Register[".gfep"L,GFEnterPoint]; Register[".gfec"L,GFEnterCubic]; Register[".gfnb"L,GFNewBoundary]; Register[".gfendpath"L,GFEndPath]; Register[".gflineobj"L,GFLineObject]; Register[".gfareaobj"L,GFAreaObject]; Register[".gftextobj"L,GFTextObject]; Register[".gfstartclu"L,GFStartCluster]; Register[".gfenterobject"L,GFEnterObject]; Register[".gfenterclu"L,GFEnterCluster]; Register[".gfclu"L,GFCluster]; Register[".gfread"L,GFReadFile]; Register[".gfmove"L,GFMove]; Register[".gfrotate"L,GFRotate]; Register[".gfscale"L,GFScale]; END.