Share project "postscript-go" into "https://postscript-go.googlecode.com/svn"

This commit is contained in:
legoff.laurent 2010-12-13 08:59:26 +00:00
parent fd18e74d18
commit d677cc1c16
40 changed files with 330269 additions and 0 deletions

18
postscript-go/.project Normal file
View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>postscript-go</name>
<comment></comment>
<projects>
<project>draw2d</project>
</projects>
<buildSpec>
<buildCommand>
<name>com.googlecode.goclipse.goBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>goclipse.goNature</nature>
</natures>
</projectDescription>

1
postscript-go/AUTHORS Normal file
View file

@ -0,0 +1 @@
Laurent Le Goff

4
postscript-go/README Normal file
View file

@ -0,0 +1,4 @@
Postscript go implementation that uses [http://code.google.com/p/draw2d/ draw2d] to generate images.
sample generation:
[http://postcript-go.googlecode.com/svn/postscript-go/TestPostscript.png]

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

18
postscript-go/bst.txt Normal file
View file

@ -0,0 +1,18 @@
Copyright (c) 2010, Laurent Le Goff
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,42 @@
Luxi fonts copyright (c) 2001 by Bigelow & Holmes Inc. Luxi font
instruction code copyright (c) 2001 by URW++ GmbH. All Rights
Reserved. Luxi is a registered trademark of Bigelow & Holmes Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of these Fonts and associated documentation files (the "Font
Software"), to deal in the Font Software, including without
limitation the rights to use, copy, merge, publish, distribute,
sublicense, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to
the following conditions:
The above copyright and trademark notices and this permission notice
shall be included in all copies of one or more of the Font Software.
The Font Software may not be modified, altered, or added to, and in
particular the designs of glyphs or characters in the Fonts may not
be modified nor may additional glyphs or characters be added to the
Fonts. This License becomes null and void when the Fonts or Font
Software have been modified.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
BIGELOW & HOLMES INC. OR URW++ GMBH. BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR
INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT
SOFTWARE.
Except as contained in this notice, the names of Bigelow & Holmes
Inc. and URW++ GmbH. shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Font Software without
prior written authorization from Bigelow & Holmes Inc. and URW++ GmbH.
For further information, contact:
info@urwpp.de
or
design@bigelowandholmes.com

View file

@ -0,0 +1,24 @@
All questions regarding this software should be directed at the
Xorg mailing list:
http://lists.freedesktop.org/mailman/listinfo/xorg
Please submit bug reports to the Xorg bugzilla:
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
The master development code repository can be found at:
git://anongit.freedesktop.org/git/xorg/font/bh-ttf
http://cgit.freedesktop.org/xorg/font/bh-ttf
For patch submission instructions, see:
http://www.x.org/wiki/Development/Documentation/SubmittingPatches
For more information on the git code manager, see:
http://wiki.x.org/wiki/GitPage

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

306339
postscript-go/spec/PLRM.pdf Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,46 @@
package main
import (
"fmt"
"log"
"os"
"bufio"
"image"
"image/png"
"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
"postscript"
)
func saveToPngFile(filePath string, m image.Image) {
f, err := os.Open(filePath, os.O_CREAT|os.O_WRONLY, 0600)
if err != nil {
log.Println(err)
os.Exit(1)
}
defer f.Close()
b := bufio.NewWriter(f)
err = png.Encode(b, m)
if err != nil {
log.Println(err)
os.Exit(1)
}
err = b.Flush()
if err != nil {
log.Println(err)
os.Exit(1)
}
fmt.Printf("Wrote %s OK.\n", filePath)
}
func main() {
i := image.NewRGBA(600, 600)
gc := draw2d.NewGraphicContext(i)
gc.Translate(0, 380)
gc.Scale(1,-1)
gc.Translate(0, -380)
interpreter := postscript.NewInterpreter(gc)
interpreter.ExecuteFile("../../test_files/tiger.ps")
saveToPngFile("../../TestPostscript.png", i)
}

View file

@ -0,0 +1,259 @@
package postscript
import (
"os"
"log"
"strconv"
"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
)
type Interpreter struct {
valueStack ValueStack
dictionaryStack DictionaryStack
gc *draw2d.GraphicContext
}
type Value interface{}
type ValueStack []Value
type Dictionary map[string]Value
type DictionaryStack []Dictionary
type Operator interface {
Execute(interpreter *Interpreter)
}
func NewInterpreter(gc *draw2d.GraphicContext) *Interpreter {
interpreter := new(Interpreter)
interpreter.valueStack = make([]Value, 0, 100)
interpreter.dictionaryStack = make([]Dictionary, 2, 10)
interpreter.dictionaryStack[0] = NewDictionary(100) // System dictionary
interpreter.dictionaryStack[1] = NewDictionary(100) // user dictionary
initSystemOperators(interpreter)
interpreter.gc = gc
return interpreter
}
func NewDictionary(prealloc int) Dictionary {
return make(Dictionary, prealloc)
}
func (interpreter *Interpreter) GetGraphicContext() *draw2d.GraphicContext {
return interpreter.gc
}
func (interpreter *Interpreter) ExecuteFile(filePath string) {
src, err := os.Open(filePath, 0, 0)
if src == nil {
log.Printf("can't open file; err=%s\n", err.String())
return
}
var scanner Scanner
scanner.Init(src)
token := scanner.Scan()
for token != EOF {
interpreter.scan(&scanner, token)
token = scanner.Scan()
}
}
func (interpreter *Interpreter) computeReference(ref string) {
value, _ := interpreter.FindValueInDictionaries(ref)
if value == nil {
log.Printf("Unknown def: %s\n", ref)
} else {
operator, isOperator := value.(Operator)
if isOperator {
operator.Execute(interpreter)
} else {
interpreter.Push(value)
}
}
}
func (interpreter *Interpreter) scan(scanner *Scanner, token int) {
if token == Ident {
interpreter.computeReference(scanner.TokenText())
} else if token == '/' {
scanner.Scan()
interpreter.Push("/" + scanner.TokenText())
} else if token == '[' {
interpreter.Push(interpreter.scanArray(scanner))
} else if token == '{' {
// procedure
interpreter.Push(interpreter.scanProcedure(scanner))
} else if token == Float || token == Int {
f, err := strconv.Atof(scanner.TokenText())
if err != nil {
log.Printf("Float expected: %s\n", scanner.TokenText())
interpreter.Push(scanner.TokenText())
} else {
interpreter.Push(f)
}
} else {
interpreter.Push(scanner.TokenText())
}
}
func (interpreter *Interpreter) scanArray(scanner *Scanner) []Value {
array := make([]Value, 0, 10)
token := scanner.Scan()
for token != EOF && token != ']' {
if token == Ident {
array = append(array, scanner.TokenText())
} else {
interpreter.scan(scanner, token)
array = append(array, interpreter.Pop())
}
token = scanner.Scan()
}
return array
}
func (interpreter *Interpreter) scanProcedure(scanner *Scanner) *ProcedureDefinition {
proceduredef := NewProcedureDefinition()
token := scanner.Scan()
for token != EOF && token != '}' {
if token == Ident {
proceduredef.Add(scanner.TokenText())
} else {
interpreter.scan(scanner, token)
proceduredef.Add(interpreter.Pop())
}
token = scanner.Scan()
}
return proceduredef
}
//Dictionary Operation
func (interpreter *Interpreter) PushDictionary(dictionary Dictionary) {
interpreter.dictionaryStack = append(interpreter.dictionaryStack, dictionary)
}
func (interpreter *Interpreter) PopDictionary() Dictionary {
stackPointer := len(interpreter.dictionaryStack) - 1
dictionary := interpreter.dictionaryStack[stackPointer]
interpreter.dictionaryStack = interpreter.dictionaryStack[0:stackPointer]
return dictionary
}
func (interpreter *Interpreter) PeekDictionary() Dictionary {
stackPointer := len(interpreter.dictionaryStack) - 1
return interpreter.dictionaryStack[stackPointer]
}
func (interpreter *Interpreter) DictionaryStackSize() int {
return len(interpreter.dictionaryStack)
}
func (interpreter *Interpreter) FindValue(name string) Value {
return interpreter.PeekDictionary()[name]
}
func (interpreter *Interpreter) FindValueInDictionaries(name string) (Value, Dictionary) {
for i := len(interpreter.dictionaryStack) - 1; i >= 0; i-- {
value := interpreter.dictionaryStack[i][name]
if value != nil {
return value, interpreter.dictionaryStack[i]
}
}
return nil, nil
}
func (interpreter *Interpreter) Define(name string, value Value) {
interpreter.PeekDictionary()[name] = value
}
func (interpreter *Interpreter) SystemDefine(name string, value Value) {
interpreter.dictionaryStack[0][name] = value
}
//Operand Operation
func (interpreter *Interpreter) Push(operand Value) {
//log.Printf("Push operand: %v\n", operand)
interpreter.valueStack = append(interpreter.valueStack, operand)
}
func (interpreter *Interpreter) Pop() Value {
valueStackPointer := len(interpreter.valueStack) - 1
operand := interpreter.valueStack[valueStackPointer]
interpreter.valueStack = interpreter.valueStack[0:valueStackPointer]
//log.Printf("Pop operand: %v\n", operand)
return operand
}
func (interpreter *Interpreter) PopValues(n int) []Value {
valueStackPointer := len(interpreter.valueStack) - 1
operands := make([]Value, n)
copy(operands, interpreter.valueStack[valueStackPointer-n+1:valueStackPointer+1])
interpreter.valueStack = interpreter.valueStack[0 : valueStackPointer-n+1]
return operands
}
func (interpreter *Interpreter) GetValues(n int) []Value {
valueStackPointer := len(interpreter.valueStack) - 1
operands := make([]Value, n)
copy(operands, interpreter.valueStack[valueStackPointer-n+1:valueStackPointer+1])
return operands
}
func (interpreter *Interpreter) Get(index int) Value {
valueStackPointer := len(interpreter.valueStack) - 1
return interpreter.valueStack[valueStackPointer-index]
}
func (interpreter *Interpreter) Peek() Value {
valueStackPointer := len(interpreter.valueStack) - 1
return interpreter.valueStack[valueStackPointer]
}
func (interpreter *Interpreter) OperandSize() int {
return len(interpreter.valueStack)
}
func (interpreter *Interpreter) PopFloat() float {
operand := interpreter.Pop()
if s, ok := operand.(string); ok {
log.Printf("Erro this is a string %s\n", s)
}
return operand.(float)
}
func (interpreter *Interpreter) PopInt() int {
f := interpreter.PopFloat()
return int(f)
}
func (interpreter *Interpreter) PopOperator() Operator {
operator := interpreter.Pop()
return operator.(Operator)
}
func (interpreter *Interpreter) PopProcedureDefinition() *ProcedureDefinition {
def := interpreter.Pop()
return def.(*ProcedureDefinition)
}
func (interpreter *Interpreter) PopName() string {
name := interpreter.Pop().(string)
return name[1:]
}
func (interpreter *Interpreter) PopString() string {
s := interpreter.Pop().(string)
return s[1 : len(s)-1]
}
func (interpreter *Interpreter) PopBoolean() bool {
s := interpreter.Pop()
return s.(bool)
}
func (interpreter *Interpreter) PopArray() []Value {
s := interpreter.Pop()
return s.([]Value)
}

View file

@ -0,0 +1,35 @@
package postscript
type OperatorFunc func(interpreter *Interpreter)
type PrimitiveOperator struct {
f OperatorFunc
}
func NewOperator(f OperatorFunc) *PrimitiveOperator {
return &PrimitiveOperator{f}
}
func (o *PrimitiveOperator) Execute(interpreter *Interpreter) {
o.f(interpreter)
}
func save(interpreter *Interpreter) {
}
func restore(interpreter *Interpreter) {
}
func initSystemOperators(interpreter *Interpreter) {
interpreter.SystemDefine("save", NewOperator(save))
interpreter.SystemDefine("restore", NewOperator(restore))
initStackOperator(interpreter)
initMathOperators(interpreter)
initDictionaryOperators(interpreter)
initRelationalOperators(interpreter)
initControlOperators(interpreter)
initDrawingOperators(interpreter)
}

View file

@ -0,0 +1,41 @@
package postscript
func ifoperator(interpreter *Interpreter) {
operator := NewProcedure(interpreter.PopProcedureDefinition())
condition := interpreter.PopBoolean()
if condition {
operator.Execute(interpreter)
}
}
func ifelse(interpreter *Interpreter) {
operator2 := NewProcedure(interpreter.PopProcedureDefinition())
operator1 := NewProcedure(interpreter.PopProcedureDefinition())
condition := interpreter.PopBoolean()
if condition {
operator1.Execute(interpreter)
} else {
operator2.Execute(interpreter)
}
}
func foroperator(interpreter *Interpreter) {
proc := NewProcedure(interpreter.PopProcedureDefinition())
limit := interpreter.PopFloat()
inc := interpreter.PopFloat()
initial := interpreter.PopFloat()
for i := initial; i <= limit; i += inc {
interpreter.Push(i)
proc.Execute(interpreter)
}
}
func initControlOperators(interpreter *Interpreter) {
interpreter.SystemDefine("if", NewOperator(ifoperator))
interpreter.SystemDefine("ifelse", NewOperator(ifelse))
interpreter.SystemDefine("for", NewOperator(foroperator))
}

View file

@ -0,0 +1,90 @@
package postscript
import (
"log"
)
func get(interpreter *Interpreter) {
name := interpreter.PopName()
dictionary := interpreter.Pop().(Dictionary)
interpreter.Push(dictionary[name])
}
func def(interpreter *Interpreter) {
value := interpreter.Pop()
name := interpreter.PopName()
if p, ok := value.(*ProcedureDefinition); ok {
value = NewProcedure(p)
}
interpreter.Define(name, value)
}
func bind(interpreter *Interpreter) {
pdef := interpreter.PopProcedureDefinition()
values := make([]Value, len(pdef.Values))
for i, value := range pdef.Values {
if s, ok := value.(string); ok {
firstChar := s[0]
if firstChar != '(' && firstChar != '/' {
v, _ := interpreter.FindValueInDictionaries(s)
operator, isOperator := v.(Operator)
if isOperator {
values[i] = operator
} else {
values[i] = value
}
} else {
values[i] = value
}
} else {
values[i] = value
}
}
pdef.Values = values
interpreter.Push(pdef)
}
func load(interpreter *Interpreter) {
name := interpreter.PopName()
value, _ := interpreter.FindValueInDictionaries(name)
if value == nil {
log.Printf("Can't find value %s\n", name)
}
interpreter.Push(value)
}
func begin(interpreter *Interpreter) {
interpreter.PushDictionary(interpreter.Pop().(Dictionary))
}
func end(interpreter *Interpreter) {
interpreter.PopDictionary()
}
func dict(interpreter *Interpreter) {
interpreter.Push(NewDictionary(interpreter.PopInt()))
}
func where(interpreter *Interpreter) {
key := interpreter.PopName()
_, dictionary := interpreter.FindValueInDictionaries(key)
if dictionary == nil {
interpreter.Push(false)
} else {
interpreter.Push(dictionary)
interpreter.Push(true)
}
}
func initDictionaryOperators(interpreter *Interpreter) {
interpreter.SystemDefine("get", NewOperator(get))
interpreter.SystemDefine("def", NewOperator(def))
interpreter.SystemDefine("load", NewOperator(load))
interpreter.SystemDefine("bind", NewOperator(bind))
interpreter.SystemDefine("begin", NewOperator(begin))
interpreter.SystemDefine("end", NewOperator(end))
interpreter.SystemDefine("dict", NewOperator(dict))
interpreter.SystemDefine("where", NewOperator(where))
}

View file

@ -0,0 +1,351 @@
package postscript
import (
"log"
"image"
"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
"math"
)
// begin Primitive Operator implementation
//Path Construction Operators
func newpath(interpreter *Interpreter) {
interpreter.GetGraphicContext().BeginPath()
}
func closepath(interpreter *Interpreter) {
interpreter.GetGraphicContext().Close()
}
func currentpoint(interpreter *Interpreter) {
x, y := interpreter.GetGraphicContext().LastPoint()
interpreter.Push(x)
interpreter.Push(y)
}
func moveto(interpreter *Interpreter) {
y := interpreter.PopFloat()
x := interpreter.PopFloat()
interpreter.GetGraphicContext().MoveTo(x, y)
}
func rmoveto(interpreter *Interpreter) {
y := interpreter.PopFloat()
x := interpreter.PopFloat()
interpreter.GetGraphicContext().RMoveTo(x, y)
}
func lineto(interpreter *Interpreter) {
y := interpreter.PopFloat()
x := interpreter.PopFloat()
interpreter.GetGraphicContext().LineTo(x, y)
}
func rlineto(interpreter *Interpreter) {
y := interpreter.PopFloat()
x := interpreter.PopFloat()
interpreter.GetGraphicContext().RLineTo(x, y)
}
func curveto(interpreter *Interpreter) {
cy3 := interpreter.PopFloat()
cx3 := interpreter.PopFloat()
cy2 := interpreter.PopFloat()
cx2 := interpreter.PopFloat()
cy1 := interpreter.PopFloat()
cx1 := interpreter.PopFloat()
interpreter.GetGraphicContext().CubicCurveTo(cx1, cy1, cx2, cy2, cx3, cy3)
}
func rcurveto(interpreter *Interpreter) {
cy3 := interpreter.PopFloat()
cx3 := interpreter.PopFloat()
cy2 := interpreter.PopFloat()
cx2 := interpreter.PopFloat()
cy1 := interpreter.PopFloat()
cx1 := interpreter.PopFloat()
interpreter.GetGraphicContext().RCubicCurveTo(cx1, cy1, cx2, cy2, cx3, cy3)
}
func clippath(interpreter *Interpreter) {
}
func stroke(interpreter *Interpreter) {
interpreter.GetGraphicContext().Stroke()
}
func fill(interpreter *Interpreter) {
interpreter.GetGraphicContext().Fill()
}
func gsave(interpreter *Interpreter) {
interpreter.GetGraphicContext().Save()
}
func grestore(interpreter *Interpreter) {
interpreter.GetGraphicContext().Restore()
}
func setgray(interpreter *Interpreter) {
gray := interpreter.PopFloat()
color := image.RGBAColor{uint8(gray * 0xff), uint8(gray * 0xff), uint8(gray * 0xff), 0xff}
interpreter.GetGraphicContext().SetStrokeColor(color)
interpreter.GetGraphicContext().SetFillColor(color)
}
func setrgbcolor(interpreter *Interpreter) {
blue := interpreter.PopFloat()
green := interpreter.PopFloat()
red := interpreter.PopFloat()
color := image.RGBAColor{uint8(red * 0xff), uint8(green * 0xff), uint8(blue * 0xff), 0xff}
interpreter.GetGraphicContext().SetStrokeColor(color)
interpreter.GetGraphicContext().SetFillColor(color)
}
func hsbtorgb(hue, saturation, brightness float) (red, green, blue int) {
var fr, fg, fb float
if saturation == 0 {
fr, fg, fb = brightness, brightness, brightness
} else {
H := (hue - float(math.Floor(float64(hue)))) * 6
I := int(math.Floor(float64(H)))
F := H - float(I)
M := brightness * (1 - saturation)
N := brightness * (1 - saturation*F)
K := brightness * (1 - saturation*(1-F))
switch I {
case 0:
fr = brightness
fg = K
fb = M
case 1:
fr = N
fg = brightness
fb = M
case 2:
fr = M
fg = brightness
fb = K
case 3:
fr = M
fg = N
fb = brightness
case 4:
fr = K
fg = M
fb = brightness
case 5:
fr = brightness
fg = M
fb = N
default:
fr, fb, fg = 0, 0, 0
}
}
red = int(fr*255. + 0.5)
green = int(fg*255. + 0.5)
blue = int(fb*255. + 0.5)
return
}
func sethsbcolor(interpreter *Interpreter) {
brightness := interpreter.PopFloat()
saturation := interpreter.PopFloat()
hue := interpreter.PopFloat()
red, green, blue := hsbtorgb(hue, saturation, brightness)
color := image.RGBAColor{uint8(red), uint8(green), uint8(blue), 0xff}
interpreter.GetGraphicContext().SetStrokeColor(color)
interpreter.GetGraphicContext().SetFillColor(color)
}
func setcmybcolor(interpreter *Interpreter) {
black := interpreter.PopFloat()
yellow := interpreter.PopFloat()
magenta := interpreter.PopFloat()
cyan := interpreter.PopFloat()
/* cyan = cyan / 255.0;
magenta = magenta / 255.0;
yellow = yellow / 255.0;
black = black / 255.0; */
red := cyan*(1.0-black) + black
green := magenta*(1.0-black) + black
blue := yellow*(1.0-black) + black
red = (1.0-red)*255.0 + 0.5
green = (1.0-green)*255.0 + 0.5
blue = (1.0-blue)*255.0 + 0.5
color := image.RGBAColor{uint8(red), uint8(green), uint8(blue), 0xff}
interpreter.GetGraphicContext().SetStrokeColor(color)
interpreter.GetGraphicContext().SetFillColor(color)
}
func setdash(interpreter *Interpreter) {
offset := interpreter.PopInt()
dash := interpreter.PopArray()
log.Printf("dash: %v, offset: %d \n", dash, offset)
}
func setlinejoin(interpreter *Interpreter) {
linejoin := interpreter.PopInt()
switch linejoin {
case 0:
interpreter.GetGraphicContext().SetLineJoin(draw2d.MiterJoin)
case 1:
interpreter.GetGraphicContext().SetLineJoin(draw2d.RoundJoin)
case 2:
interpreter.GetGraphicContext().SetLineJoin(draw2d.BevelJoin)
}
}
func setlinecap(interpreter *Interpreter) {
linecap := interpreter.PopInt()
switch linecap {
case 0:
interpreter.GetGraphicContext().SetLineCap(draw2d.ButtCap)
case 1:
interpreter.GetGraphicContext().SetLineCap(draw2d.RoundCap)
case 2:
interpreter.GetGraphicContext().SetLineCap(draw2d.SquareCap)
}
}
func setmiterlimit(interpreter *Interpreter) {
interpreter.PopInt()
}
func setlinewidth(interpreter *Interpreter) {
interpreter.GetGraphicContext().SetLineWidth(interpreter.PopFloat())
}
func showpage(interpreter *Interpreter) {
}
func show(interpreter *Interpreter) {
s := interpreter.PopString()
interpreter.GetGraphicContext().FillString(s)
}
func findfont(interpreter *Interpreter) {
}
func scalefont(interpreter *Interpreter) {
}
func setfont(interpreter *Interpreter) {
}
func stringwidth(interpreter *Interpreter) {
interpreter.Push(10.0)
interpreter.Push(10.0)
}
func setflat(interpreter *Interpreter) {
interpreter.Pop()
}
func currentflat(interpreter *Interpreter) {
interpreter.Push(1.0)
}
// Coordinate System and Matrix operators
func matrix(interpreter *Interpreter) {
interpreter.Push(draw2d.NewIdentityMatrix())
}
func transform(interpreter *Interpreter) {
y := interpreter.PopFloat()
x := interpreter.PopFloat()
interpreter.GetGraphicContext().GetMatrixTransform().Transform(&x, &y)
interpreter.Push(x)
interpreter.Push(y)
}
func itransform(interpreter *Interpreter) {
y := interpreter.PopFloat()
x := interpreter.PopFloat()
interpreter.GetGraphicContext().GetMatrixTransform().InverseTransform(&x, &y)
interpreter.Push(x)
interpreter.Push(y)
}
func translate(interpreter *Interpreter) {
y := interpreter.PopFloat()
x := interpreter.PopFloat()
interpreter.GetGraphicContext().Translate(x, y)
}
func rotate(interpreter *Interpreter) {
angle := interpreter.PopFloat()
interpreter.GetGraphicContext().Rotate(angle * (math.Pi / 180.0))
}
func scale(interpreter *Interpreter) {
y := interpreter.PopFloat()
x := interpreter.PopFloat()
interpreter.GetGraphicContext().Scale(x, y)
}
func initDrawingOperators(interpreter *Interpreter) {
interpreter.SystemDefine("stroke", NewOperator(stroke))
interpreter.SystemDefine("fill", NewOperator(fill))
interpreter.SystemDefine("show", NewOperator(show))
interpreter.SystemDefine("showpage", NewOperator(showpage))
interpreter.SystemDefine("findfont", NewOperator(findfont))
interpreter.SystemDefine("scalefont", NewOperator(scalefont))
interpreter.SystemDefine("setfont", NewOperator(setfont))
interpreter.SystemDefine("stringwidth", NewOperator(stringwidth))
// Graphic state operators
interpreter.SystemDefine("gsave", NewOperator(gsave))
interpreter.SystemDefine("grestore", NewOperator(grestore))
interpreter.SystemDefine("setrgbcolor", NewOperator(setrgbcolor))
interpreter.SystemDefine("sethsbcolor", NewOperator(sethsbcolor))
interpreter.SystemDefine("setcmybcolor", NewOperator(setcmybcolor))
interpreter.SystemDefine("setcmykcolor", NewOperator(setcmybcolor))
interpreter.SystemDefine("setgray", NewOperator(setgray))
interpreter.SystemDefine("setdash", NewOperator(setdash))
interpreter.SystemDefine("setlinejoin", NewOperator(setlinejoin))
interpreter.SystemDefine("setlinecap", NewOperator(setlinecap))
interpreter.SystemDefine("setmiterlimit", NewOperator(setmiterlimit))
interpreter.SystemDefine("setlinewidth", NewOperator(setlinewidth))
// Graphic state operators device dependent
interpreter.SystemDefine("setflat", NewOperator(setflat))
interpreter.SystemDefine("currentflat", NewOperator(currentflat))
// Coordinate System and Matrix operators
interpreter.SystemDefine("matrix", NewOperator(transform))
interpreter.SystemDefine("transform", NewOperator(transform))
interpreter.SystemDefine("itransform", NewOperator(itransform))
interpreter.SystemDefine("translate", NewOperator(translate))
interpreter.SystemDefine("rotate", NewOperator(rotate))
interpreter.SystemDefine("scale", NewOperator(scale))
//Path Construction Operators
interpreter.SystemDefine("newpath", NewOperator(newpath))
interpreter.SystemDefine("closepath", NewOperator(closepath))
interpreter.SystemDefine("currentpoint", NewOperator(currentpoint))
interpreter.SystemDefine("moveto", NewOperator(moveto))
interpreter.SystemDefine("rmoveto", NewOperator(rmoveto))
interpreter.SystemDefine("lineto", NewOperator(lineto))
interpreter.SystemDefine("rlineto", NewOperator(rlineto))
interpreter.SystemDefine("curveto", NewOperator(curveto))
interpreter.SystemDefine("rcurveto", NewOperator(rcurveto))
interpreter.SystemDefine("clippath", NewOperator(clippath))
}

View file

@ -0,0 +1,82 @@
package postscript
import (
"math"
)
// begin Primitive Operator implementation
func add(interpreter *Interpreter) {
f2 := interpreter.PopFloat()
f1 := interpreter.PopFloat()
interpreter.Push(f1 + f2)
}
func sub(interpreter *Interpreter) {
f2 := interpreter.PopFloat()
f1 := interpreter.PopFloat()
interpreter.Push(f1 - f2)
}
func div(interpreter *Interpreter) {
f2 := interpreter.PopFloat()
f1 := interpreter.PopFloat()
interpreter.Push(f1 / f2)
}
func mul(interpreter *Interpreter) {
f2 := interpreter.PopFloat()
f1 := interpreter.PopFloat()
interpreter.Push(f1 * f2)
}
func sqrt(interpreter *Interpreter) {
f := interpreter.PopFloat()
interpreter.Push(float(math.Sqrt(float64(f))))
}
func atan(interpreter *Interpreter) {
den := interpreter.PopFloat()
num := interpreter.PopFloat()
interpreter.Push(float(math.Atan2(float64(num), float64(den))) * (180.0 / math.Pi))
}
func cos(interpreter *Interpreter) {
a := interpreter.PopFloat()
interpreter.Push(float(math.Cos(float64(a))) * (180.0 / math.Pi))
}
func sin(interpreter *Interpreter) {
a := interpreter.PopFloat()
interpreter.Push(float(math.Sin(float64(a))) * (180.0 / math.Pi))
}
func neg(interpreter *Interpreter) {
f := interpreter.PopFloat()
interpreter.Push(-f)
}
func round(interpreter *Interpreter) {
f := interpreter.PopFloat()
interpreter.Push(float(int(f + 0.5)))
}
func abs(interpreter *Interpreter) {
f := interpreter.PopFloat()
interpreter.Push(float(math.Fabs(float64(f))))
}
func initMathOperators(interpreter *Interpreter) {
interpreter.SystemDefine("add", NewOperator(add))
interpreter.SystemDefine("sub", NewOperator(sub))
interpreter.SystemDefine("mul", NewOperator(mul))
interpreter.SystemDefine("div", NewOperator(div))
interpreter.SystemDefine("sqrt", NewOperator(sqrt))
interpreter.SystemDefine("cos", NewOperator(cos))
interpreter.SystemDefine("sin", NewOperator(sin))
interpreter.SystemDefine("atan", NewOperator(atan))
interpreter.SystemDefine("neg", NewOperator(neg))
interpreter.SystemDefine("round", NewOperator(round))
interpreter.SystemDefine("abs", NewOperator(abs))
}

View file

@ -0,0 +1,19 @@
package postscript
func eq(interpreter *Interpreter) {
value1 := interpreter.Pop()
value2 := interpreter.Pop()
interpreter.Push(value1 == value2)
}
func lt(interpreter *Interpreter) {
f2 := interpreter.PopFloat()
f1 := interpreter.PopFloat()
interpreter.Push(f1 < f2)
}
func initRelationalOperators(interpreter *Interpreter) {
interpreter.SystemDefine("eq", NewOperator(eq))
interpreter.SystemDefine("lt", NewOperator(lt))
}

View file

@ -0,0 +1,48 @@
package postscript
func pop(interpreter *Interpreter) {
interpreter.Pop()
}
func dup(interpreter *Interpreter) {
interpreter.Push(interpreter.Peek())
}
func index(interpreter *Interpreter) {
f := interpreter.PopInt()
interpreter.Push(interpreter.Get(int(f)))
}
func roll(interpreter *Interpreter) {
j := interpreter.PopInt()
n := interpreter.PopInt()
values := interpreter.PopValues(n)
j %= n
for i := 0; i < n; i++ {
interpreter.Push(values[(n+i-j)%n])
}
}
func copystack(interpreter *Interpreter) {
n := interpreter.PopInt()
values := interpreter.GetValues(n)
for _, value := range values {
interpreter.Push(value)
}
}
func exch(interpreter *Interpreter) {
value1 := interpreter.Pop()
value2 := interpreter.Pop()
interpreter.Push(value1)
interpreter.Push(value2)
}
func initStackOperator(interpreter * Interpreter) {
interpreter.SystemDefine("pop", NewOperator(pop))
interpreter.SystemDefine("dup", NewOperator(dup))
interpreter.SystemDefine("index", NewOperator(index))
interpreter.SystemDefine("copy", NewOperator(copystack))
interpreter.SystemDefine("roll", NewOperator(roll))
interpreter.SystemDefine("exch", NewOperator(exch))
}

View file

@ -0,0 +1,43 @@
package postscript
type ProcedureDefinition struct {
Values []Value
}
func NewProcedureDefinition() *ProcedureDefinition {
proceduredef := new(ProcedureDefinition)
proceduredef.Values = make([]Value, 0, 100)
return proceduredef
}
func (p *ProcedureDefinition) Add(value Value) {
p.Values = append(p.Values, value)
}
type Procedure struct {
def *ProcedureDefinition
}
func NewProcedure(def *ProcedureDefinition) *Procedure {
return &Procedure{def}
}
func (p *Procedure) Execute(interpreter *Interpreter) {
for _, value := range p.def.Values {
if s, ok := value.(string); ok {
firstChar := s[0]
if firstChar != '(' && firstChar != '/' {
interpreter.computeReference(s)
} else {
interpreter.Push(value)
}
} else {
operator, isOperator := value.(Operator)
if isOperator {
operator.Execute(interpreter)
} else {
interpreter.Push(value)
}
}
}
}

View file

@ -0,0 +1,601 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// postscript scanner derived form the scanner package of go sources
package postscript
import (
"bytes"
"fmt"
"io"
"os"
"unicode"
"utf8"
)
// A source position is represented by a Position value.
// A position is valid if Line > 0.
type Position struct {
Filename string // filename, if any
Offset int // byte offset, starting at 0
Line int // line number, starting at 1
Column int // column number, starting at 0 (character count per line)
}
// IsValid returns true if the position is valid.
func (pos *Position) IsValid() bool { return pos.Line > 0 }
func (pos Position) String() string {
s := pos.Filename
if pos.IsValid() {
if s != "" {
s += ":"
}
s += fmt.Sprintf("%d:%d", pos.Line, pos.Column)
}
if s == "" {
s = "???"
}
return s
}
// Predefined mode bits to control recognition of tokens. For instance,
// to configure a Scanner such that it only recognizes (Go) identifiers,
// integers, and skips comments, set the Scanner's Mode field to:
//
// ScanIdents | ScanInts | SkipComments
//
const (
ScanIdents = 1 << -Ident
ScanInts = 1 << -Int
ScanFloats = 1 << -Float // includes Ints
ScanChars = 1 << -Char
ScanStrings = 1 << -String
ScanRawStrings = 1 << -RawString
ScanComments = 1 << -Comment
SkipComments = 1 << -skipComment // if set with ScanComments, comments become white space
GoTokens = ScanIdents | ScanFloats | ScanChars | ScanStrings | ScanRawStrings | ScanComments | SkipComments
)
// The result of Scan is one of the following tokens or a Unicode character.
const (
EOF = -(iota + 1)
Ident
Int
Float
Char
String
RawString
Comment
skipComment
)
var tokenString = map[int]string{
EOF: "EOF",
Ident: "Ident",
Int: "Int",
Float: "Float",
Char: "Char",
String: "String",
RawString: "RawString",
Comment: "Comment",
}
// TokenString returns a (visible) string for a token or Unicode character.
func TokenString(tok int) string {
if s, found := tokenString[tok]; found {
return s
}
return fmt.Sprintf("U+%04X", tok)
}
// GoWhitespace is the default value for the Scanner's Whitespace field.
// Its value selects Go's white space characters.
const GoWhitespace = 1<<'\t' | 1<<'\n' | 1<<'\r' | 1<<' '
const bufLen = 1024 // at least utf8.UTFMax
// A Scanner implements reading of Unicode characters and tokens from an io.Reader.
type Scanner struct {
// Input
src io.Reader
// Source buffer
srcBuf [bufLen + 1]byte // +1 for sentinel for common case of s.next()
srcPos int // reading position (srcBuf index)
srcEnd int // source end (srcBuf index)
// Source position
srcBufOffset int // byte offset of srcBuf[0] in source
line int // newline count + 1
column int // character count on line
// Token text buffer
// Typically, token text is stored completely in srcBuf, but in general
// the token text's head may be buffered in tokBuf while the token text's
// tail is stored in srcBuf.
tokBuf bytes.Buffer // token text head that is not in srcBuf anymore
tokPos int // token text tail position (srcBuf index)
tokEnd int // token text tail end (srcBuf index)
// One character look-ahead
ch int // character before current srcPos
// Error is called for each error encountered. If no Error
// function is set, the error is reported to os.Stderr.
Error func(s *Scanner, msg string)
// ErrorCount is incremented by one for each error encountered.
ErrorCount int
// The Mode field controls which tokens are recognized. For instance,
// to recognize Ints, set the ScanInts bit in Mode. The field may be
// changed at any time.
Mode uint
// The Whitespace field controls which characters are recognized
// as white space. To recognize a character ch <= ' ' as white space,
// set the ch'th bit in Whitespace (the Scanner's behavior is undefined
// for values ch > ' '). The field may be changed at any time.
Whitespace uint64
// Current token position. The Offset, Line, and Column fields
// are set by Scan(); the Filename field is left untouched by the
// Scanner.
Position
}
// Init initializes a Scanner with a new source and returns itself.
// Error is set to nil, ErrorCount is set to 0, Mode is set to GoTokens,
// and Whitespace is set to GoWhitespace.
func (s *Scanner) Init(src io.Reader) *Scanner {
s.src = src
// initialize source buffer
s.srcBuf[0] = utf8.RuneSelf // sentinel
s.srcPos = 0
s.srcEnd = 0
// initialize source position
s.srcBufOffset = 0
s.line = 1
s.column = 0
// initialize token text buffer
s.tokPos = -1
// initialize one character look-ahead
s.ch = s.next()
// initialize public fields
s.Error = nil
s.ErrorCount = 0
s.Mode = GoTokens
s.Whitespace = GoWhitespace
return s
}
// next reads and returns the next Unicode character. It is designed such
// that only a minimal amount of work needs to be done in the common ASCII
// case (one test to check for both ASCII and end-of-buffer, and one test
// to check for newlines).
func (s *Scanner) next() int {
ch := int(s.srcBuf[s.srcPos])
if ch >= utf8.RuneSelf {
// uncommon case: not ASCII or not enough bytes
for s.srcPos+utf8.UTFMax > s.srcEnd && !utf8.FullRune(s.srcBuf[s.srcPos:s.srcEnd]) {
// not enough bytes: read some more, but first
// save away token text if any
if s.tokPos >= 0 {
s.tokBuf.Write(s.srcBuf[s.tokPos:s.srcPos])
s.tokPos = 0
}
// move unread bytes to beginning of buffer
copy(s.srcBuf[0:], s.srcBuf[s.srcPos:s.srcEnd])
s.srcBufOffset += s.srcPos
// read more bytes
i := s.srcEnd - s.srcPos
n, err := s.src.Read(s.srcBuf[i:bufLen])
s.srcEnd = i + n
s.srcPos = 0
s.srcBuf[s.srcEnd] = utf8.RuneSelf // sentinel
if err != nil {
if s.srcEnd == 0 {
return EOF
}
if err != os.EOF {
s.error(err.String())
break
}
}
}
// at least one byte
ch = int(s.srcBuf[s.srcPos])
if ch >= utf8.RuneSelf {
// uncommon case: not ASCII
var width int
ch, width = utf8.DecodeRune(s.srcBuf[s.srcPos:s.srcEnd])
if ch == utf8.RuneError && width == 1 {
s.error("illegal UTF-8 encoding")
}
s.srcPos += width - 1
}
}
s.srcPos++
s.column++
switch ch {
case 0:
// implementation restriction for compatibility with other tools
s.error("illegal character NUL")
case '\n':
s.line++
s.column = 0
}
return ch
}
// Next reads and returns the next Unicode character.
// It returns EOF at the end of the source. It reports
// a read error by calling s.Error, if set, or else
// prints an error message to os.Stderr. Next does not
// update the Scanner's Position field; use Pos() to
// get the current position.
func (s *Scanner) Next() int {
s.tokPos = -1 // don't collect token text
ch := s.ch
s.ch = s.next()
return ch
}
// Peek returns the next Unicode character in the source without advancing
// the scanner. It returns EOF if the scanner's position is at the last
// character of the source.
func (s *Scanner) Peek() int {
return s.ch
}
func (s *Scanner) error(msg string) {
s.ErrorCount++
if s.Error != nil {
s.Error(s, msg)
return
}
fmt.Fprintf(os.Stderr, "%s: %s", s.Position, msg)
}
func (s *Scanner) scanIdentifier() int {
ch := s.next() // read character after first '_' or letter
for ch == '_' || unicode.IsLetter(ch) || unicode.IsDigit(ch) || ch == '.' {
ch = s.next()
}
return ch
}
func digitVal(ch int) int {
switch {
case '0' <= ch && ch <= '9':
return ch - '0'
case 'a' <= ch && ch <= 'f':
return ch - 'a' + 10
case 'A' <= ch && ch <= 'F':
return ch - 'A' + 10
}
return 16 // larger than any legal digit val
}
func isDecimal(ch int) bool { return '0' <= ch && ch <= '9' }
func (s *Scanner) scanMantissa(ch int) int {
for isDecimal(ch) {
ch = s.next()
}
return ch
}
func (s *Scanner) scanFraction(ch int) int {
if ch == '.' {
ch = s.scanMantissa(s.next())
}
return ch
}
func (s *Scanner) scanExponent(ch int) int {
if ch == 'e' || ch == 'E' {
ch = s.next()
if ch == '-' || ch == '+' {
ch = s.next()
}
ch = s.scanMantissa(ch)
}
return ch
}
func (s *Scanner) scanNumber(ch int) (int, int) {
// isDecimal(ch)
if ch == '0' {
// int or float
ch = s.next()
if ch == 'x' || ch == 'X' {
// hexadecimal int
ch = s.next()
for digitVal(ch) < 16 {
ch = s.next()
}
} else {
// octal int or float
seenDecimalDigit := false
for isDecimal(ch) {
if ch > '7' {
seenDecimalDigit = true
}
ch = s.next()
}
if s.Mode&ScanFloats != 0 && (ch == '.' || ch == 'e' || ch == 'E') {
// float
ch = s.scanFraction(ch)
ch = s.scanExponent(ch)
return Float, ch
}
// octal int
if seenDecimalDigit {
s.error("illegal octal number")
}
}
return Int, ch
}
// decimal int or float
ch = s.scanMantissa(ch)
if s.Mode&ScanFloats != 0 && (ch == '.' || ch == 'e' || ch == 'E') {
// float
ch = s.scanFraction(ch)
ch = s.scanExponent(ch)
return Float, ch
}
return Int, ch
}
func (s *Scanner) scanDigits(ch, base, n int) int {
for n > 0 && digitVal(ch) < base {
ch = s.next()
n--
}
if n > 0 {
s.error("illegal char escape")
}
return ch
}
func (s *Scanner) scanEscape(quote int) int {
ch := s.next() // read character after '/'
switch ch {
case 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', quote:
// nothing to do
ch = s.next()
case '0', '1', '2', '3', '4', '5', '6', '7':
ch = s.scanDigits(ch, 8, 3)
case 'x':
ch = s.scanDigits(s.next(), 16, 2)
case 'u':
ch = s.scanDigits(s.next(), 16, 4)
case 'U':
ch = s.scanDigits(s.next(), 16, 8)
default:
s.error("illegal char escape")
}
return ch
}
func (s *Scanner) scanString(quote int) (n int) {
ch := s.next() // read character after quote
for ch != quote {
if ch == '\n' || ch < 0 {
s.error("literal not terminated")
return
}
if ch == '\\' {
ch = s.scanEscape(quote)
} else {
ch = s.next()
}
n++
}
return
}
func (s *Scanner) scanRawString() {
ch := s.next() // read character after '`'
for ch != '`' {
if ch < 0 {
s.error("literal not terminated")
return
}
ch = s.next()
}
}
func (s *Scanner) scanLineComment() {
ch := s.next() // read character after "//"
for ch != '\n' {
if ch < 0 {
s.error("comment not terminated")
return
}
ch = s.next()
}
}
func (s *Scanner) scanComment(ch int) {
s.scanLineComment()
}
// Scan reads the next token or Unicode character from source and returns it.
// It only recognizes tokens t for which the respective Mode bit (1<<-t) is set.
// It returns EOF at the end of the source. It reports scanner errors (read and
// token errors) by calling s.Error, if set; otherwise it prints an error message
// to os.Stderr.
func (s *Scanner) Scan() int {
ch := s.ch
// reset token text position
s.tokPos = -1
redo:
// skip white space
for s.Whitespace&(1<<uint(ch)) != 0 {
ch = s.next()
}
// start collecting token text
s.tokBuf.Reset()
s.tokPos = s.srcPos - 1
// set token position
s.Offset = s.srcBufOffset + s.tokPos
s.Line = s.line
s.Column = s.column
// determine token value
tok := ch
switch {
case unicode.IsLetter(ch) || ch == '_':
if s.Mode&ScanIdents != 0 {
tok = Ident
ch = s.scanIdentifier()
} else {
ch = s.next()
}
case ch == '-': // minus
ch = s.next()
if !isDecimal(ch) {
fmt.Printf("Error may be a digi: %c\n")
} else {
if s.Mode&(ScanInts|ScanFloats) != 0 {
tok, ch = s.scanNumber(ch)
} else {
ch = s.next()
}
}
case isDecimal(ch):
if s.Mode&(ScanInts|ScanFloats) != 0 {
tok, ch = s.scanNumber(ch)
} else {
ch = s.next()
}
default:
switch ch {
case '(':
if s.Mode&ScanStrings != 0 {
s.scanString(')')
tok = String
}
ch = s.next()
case '.':
ch = s.next()
if isDecimal(ch) && s.Mode&ScanFloats != 0 {
tok = Float
ch = s.scanMantissa(ch)
ch = s.scanExponent(ch)
}
case '%':
ch = s.next()
if s.Mode&ScanComments != 0 {
if s.Mode&SkipComments != 0 {
s.tokPos = -1 // don't collect token text
s.scanComment(ch)
ch = s.next()
goto redo
}
s.scanComment(ch)
tok = Comment
ch = s.next()
}
case '`':
if s.Mode&ScanRawStrings != 0 {
s.scanRawString()
tok = String
}
ch = s.next()
default:
ch = s.next()
}
}
// end of token text
s.tokEnd = s.srcPos - 1
s.ch = ch
return tok
}
// Position returns the current source position. If called before Next()
// or Scan(), it returns the position of the next Unicode character or token
// returned by these functions. If called afterwards, it returns the position
// immediately after the last character of the most recent token or character
// scanned.
func (s *Scanner) Pos() Position {
return Position{
s.Filename,
s.srcBufOffset + s.srcPos - 1,
s.line,
s.column,
}
}
// TokenText returns the string corresponding to the most recently scanned token.
// Valid after calling Scan().
func (s *Scanner) TokenText() string {
if s.tokPos < 0 {
// no token text
return ""
}
if s.tokEnd < 0 {
// if EOF was reached, s.tokEnd is set to -1 (s.srcPos == 0)
s.tokEnd = s.tokPos
}
if s.tokBuf.Len() == 0 {
// common case: the entire token text is still in srcBuf
return string(s.srcBuf[s.tokPos:s.tokEnd])
}
// part of the token text was saved in tokBuf: save the rest in
// tokBuf as well and return its content
s.tokBuf.Write(s.srcBuf[s.tokPos:s.tokEnd])
s.tokPos = s.tokEnd // ensure idempotency of TokenText() call
return s.tokBuf.String()
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,125 @@
%!
%/colorcirsave save def % prevent left over effects
gsave
/Times-Roman findfont 24 scalefont setfont
72 72 translate 0 0 moveto 1 0 0 setrgbcolor (Red) show
72 0 translate 0 0 moveto 0 1 0 setrgbcolor (Green) show
72 0 translate 0 0 moveto 0 0 1 setrgbcolor (Blue) show
72 0 translate 0 0 moveto 1 1 0 setrgbcolor (Yellow) show
72 0 translate 0 0 moveto 1 0 1 setrgbcolor (Pink) show
72 0 translate 0 0 moveto 0 1 1 setrgbcolor (Cyan) show
72 0 translate 0 0 moveto 0.9 0.9 0.9 setrgbcolor ('White') show
grestore
0.0 setlinewidth
/length 0.1 def
/width 0.02 def
/hsvcircle {
gsave
/h 0.0 def
0 4 360 {
pop
gsave
0.5 0.0 translate
newpath
0.0 0.0 moveto
length 0.0 lineto
length width lineto
0.0 width lineto
closepath
h 1.0 1.0 sethsbcolor
fill
%newpath
%0.0 0.0 moveto
%length 0.0 lineto
%length width lineto
%0.0 width lineto
%closepath
%0.0 setgray
%stroke
grestore
/h h 4 360 div add def
4 rotate
} for
grestore
} def
/graycircle {
gsave
/h -1.0 def
0 4 360 {
pop
gsave
0.5 0.0 translate
newpath
0.0 0.0 moveto
length 0.0 lineto
length width lineto
0.0 width lineto
closepath
h abs setgray
fill
%newpath
%0.0 0.0 moveto
%length 0.0 lineto
%length width lineto
%0.0 width lineto
%closepath
%0.0 setgray
%stroke
grestore
/h h 8 360 div add def
4 rotate
} for
grestore
} def
0.0 setlinewidth
0.0 setgray
300 400 translate
500 500 scale
30 rotate
1.0 0.7 scale
-30 rotate
hsvcircle
0.8 0.8 scale
graycircle
0.8 0.8 scale
hsvcircle
0.8 0.8 scale
graycircle
0.8 0.8 scale
hsvcircle
0.8 0.8 scale
graycircle
0.8 0.8 scale
hsvcircle
0.8 0.8 scale
graycircle
0.8 0.8 scale
hsvcircle
0.8 0.8 scale
graycircle
0.8 0.8 scale
hsvcircle
0.8 0.8 scale
graycircle
0.8 0.8 scale
hsvcircle
0.8 0.8 scale
graycircle
showpage
%clear cleardictstack
%colorcirsave restore

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,380 @@
%!
% If you're concerned that the cpu in your PostScript printer will atrophy
% from disuse, here is another Escher-like contribution to to keep it busy
% for a while. It uses PostScript color commands, but will still work on
% a monochrome printer (but isn't very pretty in black & white).
%
% The butterflies are arranged in a hexagonal grid (wallpaper group p6),
% and the moveto, lineto, curveto commands used to render the tesselation
% are redefined so as to impose a nonlinear transform that shrinks the
% infinite plane to an ellipse. This is a sleazy way to mimic Escher's
% "circle limit" sorts of things.
%
% The butterfly permimeter was made by imposing all the symmetry constraints
% on a path, and then that path was filled in using Adobe Illustrator
%
% The routines Xform and next_color are easy to change if you want to hack
% with them. The code was written to sacrifice efficiency for readability.
%
% Bob Wallis
%
% UUCP {sun,pyramid,cae780,apple}!weitek!wallis
%statusdict begin waittimeout 6000 lt % if you have a slow printer, you
% {0 60 6000 setdefaulttimeouts} % might need to uncomment this
%if end
/nlayers 1 def % 1 takes about 10 minutes on a LW+; 2 takes 4x longer
/warp 1 def % 1 -> ellipsoidal distortion; 0 -> flat Euclidean
/inch {72 mul} def
/x4 152 def /y4 205.6 def % 6 fold rotation center of bfly
/x12 387.20 def /y12 403.84 def % 3 fold center of bfly
/dx x4 x12 sub def % [dx,dy] = distance between the
/dy y4 y12 sub def % two fixed points above
/Dm dx dup mul dy dup mul % magnitude of basis vectors of
add sqrt 3 sqrt mul % parallelogram lattice
def % = |dx,dy| * sqrt(3)
/Da dy dx atan 30 add def
/D1x Dm Da cos mul def % [D1x, D1y] = basis vector vector #1
/D1y Dm Da sin mul def % = [Dm,0] exp(j30)
/Da dy dx atan 30 sub def
/D2x Dm Da cos mul def % [D2x, D2y] = basis vector vector #2
/D2y Dm Da sin mul def % = [Dm,0] exp(-j30)
/m { moveto} def
/L {lineto} def
/S {stroke} def
/c {curveto} def
/f {closepath fill} def
/F {closepath fill} def
/g { setgray} def
/FillStroke { % fill interior & stroke black border
closepath gsave fill grestore 0 setgray stroke
} def
%
% Description of 1 butterfly
%
/body {
314.96 280.19 m
383.4 261.71 445.11 243.23 513.52 224.68 c
463.68 256.59 490.26 328.83 446.99 360.76 c
423.71 347.32 397.08 339.7 367.07 337.9 c
388.93 358.28 414.14 372.84 442.73 381.58 c
426.68 398.18 394.07 389.7 387.2 403.84 c
371.52 404.96 362.56 372.48 340.16 366.88 c
346.88 396.01 346.88 425.12 340.16 454.24 c
326.72 427.35 320 400.48 320 373.6 c
270.71 352.1 221.44 411.23 168.88 384.02 c
189.04 388.03 202.48 380.4 212.57 366.95 c
216.72 350.85 209.23 341.46 190.1 338.79 c
177.34 343.57 167.94 354.17 161.9 370.59 c
176.06 305.52 132.02 274.05 152 205.6 c
201.29 257.12 250.56 234.72 299.84 279.52 c
288.64 266.08 284.16 252.64 286.4 239.2 c
298.27 223.97 310.15 222.18 322.02 233.82 c
328.62 249.28 328.51 264.74 314.96 280.19 c
FillStroke
} def
/eyes {
294.8125 238.3246 m
296.9115 238.3246 298.6132 242.7964 298.6132 248.3125 c
298.6132 253.8286 296.9115 258.3004 294.8125 258.3004 c
292.7135 258.3004 291.0118 253.8286 291.0118 248.3125 c
291.0118 242.7964 292.7135 238.3246 294.8125 238.3246 c
closepath gsave 1 g fill grestore 0 g S
319.5 241.1782 m
321.7455 241.1782 323.5659 245.4917 323.5659 250.8125 c
323.5659 256.1333 321.7455 260.4468 319.5 260.4468 c
317.2545 260.4468 315.4341 256.1333 315.4341 250.8125 c
315.4341 245.4917 317.2545 241.1782 319.5 241.1782 c
closepath gsave 1 g fill grestore 0 g S
0 g
296.875 242.0939 m
297.4608 242.0939 297.9356 243.479 297.9356 245.1875 c
297.9356 246.896 297.4608 248.2811 296.875 248.2811 c
296.2892 248.2811 295.8143 246.896 295.8143 245.1875 c
295.8143 243.479 296.2892 242.0939 296.875 242.0939 c
f
0 g
318.5 243.7707 m
319.281 243.7707 319.9142 245.0766 319.9142 246.6875 c
319.9142 248.2984 319.281 249.6043 318.5 249.6043 c
317.719 249.6043 317.0858 248.2984 317.0858 246.6875 c
317.0858 245.0766 317.719 243.7707 318.5 243.7707 c
f
} def
/stripes {
292 289 m
252 294 241 295 213 279 c
185 263 175 252 159 222 c
S
285 313 m
239 326 226 325 206 315 c
186 305 164 278 161 267 c
S
298 353 m
262 342 251 339 237 355 c
223 371 213 380 201 383 c
S
330 288 m
384 293 385 292 418 280 c
451 268 452 264 473 247 c
S
342 306 m
381 311 386 317 410 311 c
434 305 460 287 474 262 c
S
345 321 m
352 357 359 367 379 377 c
399 387 409 385 426 382 c
S
327.75 367.75 m
336.5 392.25 333.682 403.348 335.25 415.5 c
S
320 364.75 m
322 361.75 323.5 360.5 326.25 360 c
329 359.5 332 360.5 334 362.75 c
S
316.25 356.5 m
318.75 353.25 320 353 323.25 352.25 c
326.5 351.5 329 352 331.5 353.25 c
S
312.5 349 m
316.75 345.5 318.25 344.5 321.25 343.75 c
324.25 343 327 344 329.75 346 c
S
310.75 340.75 m
314.25 336.5 316.25 335.25 320 335.25 c
323.75 335.25 327 336.5 329.25 338 c
S
308.5 332 m
311.75 328.5 312.5 327.25 317 327 c
321.5 326.75 325.75 328.25 327.75 329.75 c
S
305 322 m
309.5 317.75 310.75 317 315 316.5 c
319.25 316 322.25 318 324.75 320 c
S
302.25 311 m
307 307.5 307.75 306.25 312.75 306 c
317.75 305.75 320 307.25 323.75 309.5 c
S
301.25 298.25 m
304.5 292.75 305.25 292 308.25 292 c
311.25 292 313.75 293.75 315.75 295.75 c
S
} def
/nostrils {
0 g
304.062 227.775 m
304.599 227.775 305.034 228.883 305.034 230.25 c
305.034 231.616 304.599 232.724 304.062 232.724 c
303.525 232.724 303.09 231.616 303.09 230.25 c
303.09 228.883 303.525 227.775 304.062 227.775 c
f
304.062 230.25 m
F
309.562 228.275 m
310.099 228.275 310.534 229.383 310.534 230.75 c
310.534 232.116 310.099 233.224 309.562 233.224 c
309.025 233.224 308.59 232.116 308.59 230.75 c
308.59 229.383 309.025 228.275 309.562 228.275 c
f
} def
/thorax
{
327.5 300 m
316.5 283 315.5 275.5 308 277.5 c
294 311.5 299 313.5 304 334 c
309 354.5 315.5 362 322.5 372 c
329.5 382 327.5 376.5 331 376 c
334.5 375.5 339.1367 379.1109 339 369 c
338.5 332 333.4999 324.5 330.5 311.5 c
0 g S
} def
/spots {
next_color
192 242.201 m
202.1535 242.201 210.3848 251.0655 210.3848 262 c
210.3848 272.9345 202.1535 281.799 192 281.799 c
181.8465 281.799 173.6152 272.9345 173.6152 262 c
173.6152 251.0655 181.8465 242.201 192 242.201 c
FillStroke
next_color
447.5 250.2365 m
459.6061 250.2365 469.4203 257.5181 469.4203 266.5 c
469.4203 275.4819 459.6061 282.7635 447.5 282.7635 c
435.3939 282.7635 425.5797 275.4819 425.5797 266.5 c
425.5797 257.5181 435.3939 250.2365 447.5 250.2365 c
FillStroke
next_color
401 369.1005 m
409.5914 369.1005 416.5563 373.5327 416.5563 379 c
416.5563 384.4673 409.5914 388.8995 401 388.8995 c
392.4086 388.8995 385.4436 384.4673 385.4436 379 c
385.4436 373.5327 392.4086 369.1005 401 369.1005 c
FillStroke
next_color
249 348.2721 m
261.4966 348.2721 271.6274 353.9707 271.6274 361 c
271.6274 368.0293 261.4966 373.7279 249 373.7279 c
236.5034 373.7279 226.3726 368.0293 226.3726 361 c
226.3726 353.9707 236.5034 348.2721 249 348.2721 c
FillStroke
} def
/ncolor 6 def
/cidx 0 def
/next_color {
cidx ncolor div % hue
.75 % saturation (change these if you like)
.8 % lightness
sethsbcolor
/cidx cidx 1 add ncolor mod def
} def
/cidx 0 def
/max_r2 % radius^2 for center of outermost ring of butterflies
Dm nlayers mul 1.05 mul dup mul
def
/max_radius max_r2 sqrt def
/max_radius_inv 1 max_radius div def
/Dm_inv 1 Dm div def
%
% Ellipsoidal distortion, maps "nlayers" concentric rings of cells into
% an ellipse centered on page
% D length of 1 basis vector separating hexagonal cells
% z0 center of 6-fold rotation = origin of shrink xform
% z' = (z - z0)/D new coord system
% |z'| = sqrt(x^2 + [(8.5/11)*y]^2) aspect ratio of paper
% z" = z' * a/M(|z'|) shrink by "a/M(|z|)" as fcn of radius
% At the max radius, we want the shrunk ellipse to be "W" units wide so it
% just fits our output format - solve for scale factor "a"
% zmax = n+0.5 for n layers of cells
% zmax * [a/M(zmax)] = W 1/2 width of output on paper
% a = M(zmax)*W/zmax solve for "a"
%/M{dup mul 1 add sqrt}bind def % M(u) = sqrt(1+|u|^2) = one possible shrink
/M { 1.5 add } bind def % M(u) = (1.5+|u|) = another possible one
/W 3.8 inch def % 1/2 width of ellipse
/zmax 0.5 nlayers add def % radius at last layer of hexagons
/a zmax M W mul zmax div def % a = M(zmax)*W/zmax
/Xform { % [x0,y0] = ctr ellipse
Matrix transform
/y exch def
/x exch def
/z x dup mul y .773 mul dup mul add sqrt def % ellipse radius
/Scale a z M div def % z=a/M(|z|)
x Scale mul x0 add % magnify back up
y Scale mul y0 add % [x0+x*s, y0+y*s]
} bind def
/Helvetica findfont 8 scalefont setfont
4.25 inch 0.5 inch moveto
(RHW) stringwidth pop -0.5 mul 0 rmoveto
(RHW) show % autograph
warp 1 eq { % redefine commands to use Xform
/moveto { Xform //moveto} def
/lineto { Xform //lineto} def
/curveto {
Xform 6 -2 roll
Xform 6 -2 roll
Xform 6 -2 roll
//curveto
} def
}if
/bfly { % paint 1 butterfly
next_color body
1 setgray eyes
stripes
0 setgray nostrils
0.5 setgray thorax next_color
spots
} def
/x0 x4 def % center
/y0 y4 def
/T1matrix % xlate to center of image
x0 neg y0 neg matrix translate
def
/Smatrix % scale so that 1 basis vector = 1.0
Dm_inv dup matrix scale
def
/HexCell { % 6 butterflys rotated about center of
/cidx 0 def % 6 fold symmetry
/color 0 def
/T2matrix dx dy matrix translate def
0 60 300 {
/angle exch def
/Rmatrix angle matrix rotate def
/Matrix % translate, rotate, scale - used by Xform
T1matrix Rmatrix matrix concatmatrix
T2matrix matrix concatmatrix
Smatrix matrix concatmatrix
def
gsave
warp 0 eq % then may use usual PostScript machinery
{ % else using Xform
x0 y0 translate angle rotate
.5 dup scale
dx x0 sub dy y0 sub translate
} if
bfly
next_color
grestore
} for
} def
%320 x4 sub 240 y4 sub translate
4.25 inch x4 sub 5.5 inch y4 sub translate
0 setlinewidth
/N 2 def
N neg 1 N {
/i exch def % translate to
N neg 1 N { % i*D1 + j*D2
/j exch def % and draw HexCell
gsave
/dx i D1x mul j D2x mul add def % translate HexCell by
/dy i D1y mul j D2y mul add def % [dx,dy]
/r2 dx dup mul dy dup mul add def % r^2 = |dx,dy|^2
r2 max_r2 lt % inside radius?
{ % yes
1 r2 max_r2 div sub sqrt 2 div
setlinewidth % make skinnier lines
HexCell % 6 butterflies
}
if
grestore
} for
} for
showpage

View file

@ -0,0 +1,917 @@
%!PS-Adobe-3.0 Resource-Form
%%Title: GRADE
%%DocumentFonts: (atend)
%%Creator: Proform III by Lytrod Software, Inc.
%%CreationDate: Mon Jun 29 14:17:21 1998
%%For: Version 4.00A Serial #012345
%%Pages: (atend)
%%BoundingBox (atend)
%%KDKAccentColor:
%%EndComments
%-----convenience definitions
/pxlk 1. def
/rd{.25 sub round .25 add}bind def
/tf{transform rd exch rd exch itransform}bind def
/m{pxlk .9 lt{moveto}{tf moveto}ifelse}bind def
/l{pxlk .9 lt{lineto}{tf lineto}ifelse}bind def
/gs{gsave}bind def
/gr{grestore}bind def
/sg{setgray}bind def
/sl{setlinewidth}bind def
/sj{setlinejoin}bind def
/sd{setdash}bind def
/np{newpath}bind def
/sk{stroke}bind def
/ep{closepath}bind def
/tr{pxlk .9 lt{translate}{tf translate}ifelse}bind def
/sc{scale}bind def
/sw{stringwidth}bind def
/rot{rotate}bind def
/tl{gs m show gr}bind def
/lrot{gs m exch rot show gr}bind def
/ssf{findfont exch makefont setfont}bind def
%-----end of standard definitions
%%EndProlog
% initialization
[12 0 0 12 0 0] /Courier ssf
%%Page: 1 1
612 0 tr
90 rot
0 612 tr
1 -1 sc
[12 0 0 -12 0 0] /Courier ssf
np
19.92 sl
0 setlinecap
0.078 0 0.125 0 setcmykcolor
58.56 118.08 m
281.28 118.08 l
sk
13.2 sl
294.72 121.44 m
317.28 121.44 l
sk
357.84 121.44 m
382.56 121.44 l
sk
389.28 121.44 m
411.84 121.44 l
sk
452.16 121.44 m
476.88 121.44 l
sk
483.84 121.44 m
506.4 121.44 l
sk
546.72 121.44 m
571.44 121.44 l
sk
598.56 121.44 m
623.28 121.44 l
sk
708.72 121.44 m
733.44 121.44 l
sk
8.88 sl
58.56 141.84 m
281.28 141.84 l
sk
389.28 141.84 m
477.12 141.84 l
sk
483.84 141.84 m
571.68 141.84 l
sk
578.16 141.84 m
733.44 141.84 l
sk
294.72 142.08 m
382.32 142.08 l
sk
294.72 159.36 m
382.32 159.36 l
sk
58.56 159.84 m
281.28 159.84 l
sk
389.28 159.84 m
477.12 159.84 l
sk
483.84 159.84 m
571.68 159.84 l
sk
578.16 159.84 m
733.44 159.84 l
sk
58.56 177.84 m
281.28 177.84 l
sk
294.72 177.84 m
382.32 177.84 l
sk
389.28 177.84 m
477.12 177.84 l
sk
483.84 177.84 m
571.68 177.84 l
sk
578.16 177.84 m
733.44 177.84 l
sk
58.56 195.84 m
281.28 195.84 l
sk
294.72 195.84 m
382.32 195.84 l
sk
389.28 195.84 m
477.12 195.84 l
sk
483.84 195.84 m
571.68 195.84 l
sk
578.16 195.84 m
733.44 195.84 l
sk
58.56 213.84 m
281.28 213.84 l
sk
294.72 213.84 m
382.32 213.84 l
sk
389.28 213.84 m
477.12 213.84 l
sk
483.84 213.84 m
571.68 213.84 l
sk
578.16 213.84 m
733.44 213.84 l
sk
58.56 231.84 m
281.28 231.84 l
sk
294.72 231.84 m
382.32 231.84 l
sk
389.28 231.84 m
477.12 231.84 l
sk
483.84 231.84 m
571.68 231.84 l
sk
578.16 231.84 m
733.44 231.84 l
sk
58.56 249.84 m
281.28 249.84 l
sk
294.72 249.84 m
382.32 249.84 l
sk
389.28 249.84 m
477.12 249.84 l
sk
483.84 249.84 m
571.68 249.84 l
sk
578.16 249.84 m
733.44 249.84 l
sk
58.56 267.84 m
281.28 267.84 l
sk
294.72 267.84 m
382.32 267.84 l
sk
389.28 267.84 m
477.12 267.84 l
sk
483.84 267.84 m
571.68 267.84 l
sk
578.16 267.84 m
733.44 267.84 l
sk
58.56 285.84 m
281.28 285.84 l
sk
294.72 285.84 m
382.32 285.84 l
sk
389.28 285.84 m
477.12 285.84 l
sk
483.84 285.84 m
571.68 285.84 l
sk
578.16 285.84 m
733.44 285.84 l
sk
19.92 sl
58.56 421.92 m
281.28 421.92 l
sk
13.2 sl
294.72 425.28 m
317.28 425.28 l
sk
357.84 425.28 m
382.56 425.28 l
sk
389.28 425.28 m
411.84 425.28 l
sk
452.16 425.28 m
476.88 425.28 l
sk
483.84 425.28 m
506.4 425.28 l
sk
546.72 425.28 m
571.44 425.28 l
sk
598.56 425.28 m
623.28 425.28 l
sk
708.72 425.28 m
733.44 425.28 l
sk
8.88 sl
58.56 445.68 m
281.28 445.68 l
sk
389.28 445.68 m
477.12 445.68 l
sk
483.84 445.68 m
571.68 445.68 l
sk
578.16 445.68 m
733.44 445.68 l
sk
294.72 445.92 m
382.32 445.92 l
sk
294.72 463.2 m
382.32 463.2 l
sk
58.56 463.68 m
281.28 463.68 l
sk
389.28 463.68 m
477.12 463.68 l
sk
483.84 463.68 m
571.68 463.68 l
sk
578.16 463.68 m
733.44 463.68 l
sk
58.56 481.68 m
281.28 481.68 l
sk
294.72 481.68 m
382.32 481.68 l
sk
389.28 481.68 m
477.12 481.68 l
sk
483.84 481.68 m
571.68 481.68 l
sk
578.16 481.68 m
733.44 481.68 l
sk
58.56 499.68 m
281.28 499.68 l
sk
294.72 499.68 m
382.32 499.68 l
sk
389.28 499.68 m
477.12 499.68 l
sk
483.84 499.68 m
571.68 499.68 l
sk
578.16 499.68 m
733.44 499.68 l
sk
58.56 517.68 m
281.28 517.68 l
sk
294.72 517.68 m
382.32 517.68 l
sk
389.28 517.68 m
477.12 517.68 l
sk
483.84 517.68 m
571.68 517.68 l
sk
578.16 517.68 m
733.44 517.68 l
sk
58.56 535.68 m
281.28 535.68 l
sk
294.72 535.68 m
382.32 535.68 l
sk
389.28 535.68 m
477.12 535.68 l
sk
483.84 535.68 m
571.68 535.68 l
sk
578.16 535.68 m
733.44 535.68 l
sk
58.56 553.68 m
281.28 553.68 l
sk
294.72 553.68 m
382.32 553.68 l
sk
389.28 553.68 m
477.12 553.68 l
sk
483.84 553.68 m
571.68 553.68 l
sk
578.16 553.68 m
733.44 553.68 l
sk
58.56 571.68 m
281.28 571.68 l
sk
294.72 571.68 m
382.32 571.68 l
sk
389.28 571.68 m
477.12 571.68 l
sk
483.84 571.68 m
571.68 571.68 l
sk
578.16 571.68 m
733.44 571.68 l
sk
58.56 589.68 m
281.28 589.68 l
sk
294.72 589.68 m
382.32 589.68 l
sk
389.28 589.68 m
477.12 589.68 l
sk
483.84 589.68 m
571.68 589.68 l
sk
578.16 589.68 m
733.44 589.68 l
sk
1 1 0 0 setcmykcolor
278.16 29.28 m
594.72 35.28 6 270 0 arc
600.72 38.16 l
272.16 38.16 l
278.16 35.28 6 180 270 arc
ep
0.078 0 0.125 0 setcmykcolor
fill
1 1 0 0 setcmykcolor
611.04 29.28 m
747.6 35.28 6 270 0 arc
753.6 38.16 l
605.04 38.16 l
611.04 35.28 6 180 270 arc
ep
0.078 0 0.125 0 setcmykcolor
fill
1 1 0 0 setcmykcolor
278.16 333.12 m
594.72 339.12 6 270 0 arc
600.72 342 l
272.16 342 l
278.16 339.12 6 180 270 arc
ep
0.078 0 0.125 0 setcmykcolor
fill
1 1 0 0 setcmykcolor
611.04 333.12 m
747.6 339.12 6 270 0 arc
753.6 342 l
605.04 342 l
611.04 339.12 6 180 270 arc
ep
0.078 0 0.125 0 setcmykcolor
fill
0.72 sl
2 setlinecap
1 1 0 0 setcmykcolor
499.44 29.04 m
499.44 55.92 l
519.6 29.04 m
519.6 55.92 l
272.16 38.16 m
600.48 38.16 l
605.04 38.16 m
753.6 38.16 l
58.32 83.04 m
58.32 289.92 l
733.44 83.04 m
733.44 289.92 l
294.72 98.88 m
382.32 98.88 l
317.04 98.88 m
317.04 289.92 l
357.6 98.88 m
357.6 289.92 l
389.04 98.88 m
476.64 98.88 l
411.6 98.88 m
411.6 289.92 l
452.16 98.88 m
452.16 289.92 l
483.6 98.88 m
571.2 98.88 l
506.16 98.88 m
506.16 289.92 l
546.72 98.88 m
546.72 289.92 l
578.16 98.88 m
733.2 98.88 l
598.32 98.88 m
598.32 289.92 l
623.04 98.88 m
623.04 289.92 l
663.6 98.88 m
663.6 289.92 l
708.72 98.88 m
708.72 289.92 l
294.72 114.72 m
294.72 128.16 l
294.72 114.72 m
317.04 114.72 l
357.6 114.72 m
382.32 114.72 l
389.04 114.72 m
411.36 114.72 l
452.16 114.72 m
476.88 114.72 l
483.6 114.72 m
505.92 114.72 l
546.72 114.72 m
571.44 114.72 l
598.32 114.72 m
623.04 114.72 l
708.72 114.72 m
733.44 114.72 l
40.32 128.16 m
281.04 128.16 l
294.72 128.16 m
382.32 128.16 l
389.04 128.16 m
476.64 128.16 l
483.6 128.16 m
571.2 128.16 l
578.16 128.16 m
751.2 128.16 l
40.32 146.16 m
281.04 146.16 l
294.72 146.16 m
382.32 146.16 l
389.04 146.16 m
476.64 146.16 l
483.6 146.16 m
571.2 146.16 l
578.16 146.16 m
751.2 146.16 l
40.32 164.16 m
281.04 164.16 l
294.72 164.16 m
382.32 164.16 l
389.04 164.16 m
476.64 164.16 l
483.6 164.16 m
571.2 164.16 l
578.16 164.16 m
751.2 164.16 l
40.32 182.16 m
281.04 182.16 l
294.72 182.16 m
382.32 182.16 l
389.04 182.16 m
476.64 182.16 l
483.6 182.16 m
571.2 182.16 l
578.16 182.16 m
751.2 182.16 l
40.32 200.16 m
281.04 200.16 l
294.72 200.16 m
382.32 200.16 l
389.04 200.16 m
476.64 200.16 l
483.6 200.16 m
571.2 200.16 l
578.16 200.16 m
751.2 200.16 l
40.32 218.16 m
281.04 218.16 l
294.72 218.16 m
382.32 218.16 l
389.04 218.16 m
476.64 218.16 l
483.6 218.16 m
571.2 218.16 l
578.16 218.16 m
751.2 218.16 l
40.32 236.16 m
281.04 236.16 l
294.72 236.16 m
382.32 236.16 l
389.04 236.16 m
476.64 236.16 l
483.6 236.16 m
571.2 236.16 l
578.16 236.16 m
751.2 236.16 l
40.32 254.16 m
281.04 254.16 l
294.72 254.16 m
382.32 254.16 l
389.04 254.16 m
476.64 254.16 l
483.6 254.16 m
571.2 254.16 l
578.16 254.16 m
751.2 254.16 l
40.32 272.16 m
281.04 272.16 l
294.72 272.16 m
382.32 272.16 l
389.04 272.16 m
476.64 272.16 l
483.6 272.16 m
571.2 272.16 l
578.16 272.16 m
751.2 272.16 l
40.32 290.16 m
281.04 290.16 l
294.72 290.16 m
382.32 290.16 l
389.04 290.16 m
476.64 290.16 l
483.6 290.16 m
571.2 290.16 l
578.16 290.16 m
751.2 290.16 l
499.44 332.88 m
499.44 359.76 l
519.6 332.88 m
519.6 359.76 l
272.16 342 m
600.48 342 l
605.04 342 m
753.6 342 l
58.32 386.88 m
58.32 593.76 l
733.44 386.88 m
733.44 593.76 l
294.72 402.72 m
382.32 402.72 l
317.04 402.72 m
317.04 593.76 l
357.6 402.72 m
357.6 593.76 l
389.04 402.72 m
476.64 402.72 l
411.6 402.72 m
411.6 593.76 l
452.16 402.72 m
452.16 593.76 l
483.6 402.72 m
571.2 402.72 l
506.16 402.72 m
506.16 593.76 l
546.72 402.72 m
546.72 593.76 l
578.16 402.72 m
733.2 402.72 l
598.32 402.72 m
598.32 593.76 l
623.04 402.72 m
623.04 593.76 l
663.6 402.72 m
663.6 593.76 l
708.72 402.72 m
708.72 593.76 l
294.72 418.32 m
317.04 418.32 l
294.72 418.32 m
294.72 431.76 l
sk
357.6 418.32 m
382.32 418.32 l
389.04 418.32 m
411.36 418.32 l
452.16 418.32 m
476.88 418.32 l
483.6 418.32 m
505.92 418.32 l
546.72 418.32 m
571.44 418.32 l
598.32 418.32 m
623.04 418.32 l
708.72 418.32 m
733.44 418.32 l
40.32 432 m
281.04 432 l
294.72 432 m
382.32 432 l
389.04 432 m
476.64 432 l
483.6 432 m
571.2 432 l
578.16 432 m
751.2 432 l
40.32 450 m
281.04 450 l
294.72 450 m
382.32 450 l
389.04 450 m
476.64 450 l
483.6 450 m
571.2 450 l
578.16 450 m
751.2 450 l
40.32 468 m
281.04 468 l
294.72 468 m
382.32 468 l
389.04 468 m
476.64 468 l
483.6 468 m
571.2 468 l
578.16 468 m
751.2 468 l
40.32 486 m
281.04 486 l
294.72 486 m
382.32 486 l
389.04 486 m
476.64 486 l
483.6 486 m
571.2 486 l
578.16 486 m
751.2 486 l
40.32 504 m
281.04 504 l
294.72 504 m
382.32 504 l
389.04 504 m
476.64 504 l
483.6 504 m
571.2 504 l
578.16 504 m
751.2 504 l
40.32 522 m
281.04 522 l
294.72 522 m
382.32 522 l
389.04 522 m
476.64 522 l
483.6 522 m
571.2 522 l
578.16 522 m
751.2 522 l
40.32 540 m
281.04 540 l
294.72 540 m
382.32 540 l
389.04 540 m
476.64 540 l
483.6 540 m
571.2 540 l
578.16 540 m
751.2 540 l
40.32 558 m
281.04 558 l
294.72 558 m
382.32 558 l
389.04 558 m
476.64 558 l
483.6 558 m
571.2 558 l
578.16 558 m
751.2 558 l
40.32 576 m
281.04 576 l
294.72 576 m
382.32 576 l
389.04 576 m
476.64 576 l
483.6 576 m
571.2 576 l
578.16 576 m
751.2 576 l
40.32 594 m
281.04 594 l
294.72 594 m
382.32 594 l
389.04 594 m
476.64 594 l
483.6 594 m
571.2 594 l
578.16 594 m
751.2 594 l
sk
0 setlinecap
47.04 29.28 m
260.16 35.28 6 270 0 arc
260.16 68.4 6 0 90 arc
47.04 68.4 6 90 180 arc
47.04 35.28 6 180 270 arc
sk
278.16 29.28 m
594.72 35.28 6 270 0 arc
600.72 56.4 l
272.16 56.4 l
278.16 35.28 6 180 270 arc
sk
611.28 29.28 m
747.84 35.28 6 270 0 arc
753.84 56.4 l
605.28 56.4 l
611.28 35.28 6 180 270 arc
sk
46.56 83.28 m
275.28 89.28 6 270 0 arc
281.28 290.4 l
40.56 290.4 l
46.56 89.28 6 180 270 arc
sk
300.72 83.28 m
376.56 89.28 6 270 0 arc
382.56 290.4 l
294.72 290.4 l
300.72 89.28 6 180 270 arc
sk
395.28 83.28 m
471.12 89.28 6 270 0 arc
477.12 290.4 l
389.28 290.4 l
395.28 89.28 6 180 270 arc
sk
489.84 83.28 m
565.68 89.28 6 270 0 arc
571.68 290.4 l
483.84 290.4 l
489.84 89.28 6 180 270 arc
sk
584.16 83.28 m
745.44 89.28 6 270 0 arc
751.44 290.4 l
578.16 290.4 l
584.16 89.28 6 180 270 arc
sk
47.04 333.12 m
260.16 339.12 6 270 0 arc
260.16 372.24 6 0 90 arc
47.04 372.24 6 90 180 arc
47.04 339.12 6 180 270 arc
sk
278.16 333.12 m
594.72 339.12 6 270 0 arc
600.72 360.24 l
272.16 360.24 l
278.16 339.12 6 180 270 arc
sk
611.28 333.12 m
747.84 339.12 6 270 0 arc
753.84 360.24 l
605.28 360.24 l
611.28 339.12 6 180 270 arc
sk
46.56 387.12 m
275.28 393.12 6 270 0 arc
281.28 594.24 l
40.56 594.24 l
46.56 393.12 6 180 270 arc
sk
300.72 387.12 m
376.56 393.12 6 270 0 arc
382.56 594.24 l
294.72 594.24 l
300.72 393.12 6 180 270 arc
sk
395.28 387.12 m
471.12 393.12 6 270 0 arc
477.12 594.24 l
389.28 594.24 l
395.28 393.12 6 180 270 arc
sk
489.84 387.12 m
565.68 393.12 6 270 0 arc
571.68 594.24 l
483.84 594.24 l
489.84 393.12 6 180 270 arc
sk
584.16 387.12 m
745.44 393.12 6 270 0 arc
751.44 594.24 l
578.16 594.24 l
584.16 393.12 6 180 270 arc
sk
[8 0 0 -8 0 0] /Helvetica-Narrow ssf
(STUDENT NAME) 274.8 36.72 tl
(NUMBER) 522.48 36.72 tl
(COUNSELOR) 607.68 36.96 tl
(COURSE TITLE) 61.68 96.24 tl
(TEACHER) 179.76 123.12 tl
(STUDENT NAME) 274.8 340.56 tl
(NUMBER) 522.48 340.56 tl
(COUNSELOR) 607.92 340.56 tl
(COURSE TITLE) 61.68 399.84 tl
(TEACHER) 179.76 426.72 tl
(Designed using Lytrod Software products. 800 /4 LYTROD.) 562.56 599.04 tl
[4 0 0 -4 0 0] /Helvetica-Narrow-Bold ssf
(GRADE) 503.76 33.6 tl
(LEVEL) 504.96 37.2 tl
(GRADE) 503.76 337.44 tl
(LEVEL) 504.96 341.04 tl
[18 0 0 -18 0 0] /Helvetica-Bold ssf
(STUDENT GRADE REPORT) 515.04 75.84 tl
(STUDENT GRADE REPORT) 515.04 379.44 tl
[7 0 0 -7 0 0] /Helvetica-Narrow ssf
(GRADE) 296.16 109.44 tl
(ABS.) 363.84 109.44 tl
(GRADE) 390.48 109.44 tl
(ABS.) 458.16 109.44 tl
(GRADE) 485.04 109.44 tl
(ABS.) 552.72 109.44 tl
(GRADE) 600.96 109.44 tl
(ABS.) 714.72 109.44 tl
(COMMENTS) 669.36 111.6 tl
(FINAL) 580.56 112.08 tl
(CREDITS) 631.2 112.08 tl
(COMMENTS) 320.64 115.68 tl
(COMMENTS) 415.2 115.68 tl
(COMMENTS) 509.76 115.68 tl
(EXAM) 580.56 120.24 tl
(EARNED) 631.92 120.24 tl
(\(SEE BACK\)) 321.12 123.84 tl
(\(SEE BACK\)) 415.68 123.84 tl
(\(SEE BACK\)) 510.24 123.84 tl
(CIT.) 300.72 124.08 tl
(TARDY) 360.72 124.08 tl
(CIT.) 394.8 124.08 tl
(TARDY) 455.04 124.08 tl
(CIT.) 489.36 124.08 tl
(TARDY) 549.6 124.08 tl
(CIT.) 605.52 124.08 tl
(TARDY) 711.6 124.08 tl
(GRADE) 296.16 413.28 tl
(ABS.) 363.84 413.28 tl
(GRADE) 390.48 413.28 tl
(ABS.) 458.16 413.28 tl
(GRADE) 485.04 413.28 tl
(ABS.) 552.72 413.28 tl
(GRADE) 600.96 413.28 tl
(ABS.) 714.72 413.28 tl
(COMMENTS) 669.36 415.2 tl
(FINAL) 580.56 415.92 tl
(CREDITS) 631.2 415.92 tl
(COMMENTS) 320.64 419.52 tl
(COMMENTS) 415.2 419.52 tl
(COMMENTS) 509.76 419.52 tl
(EXAM) 580.56 424.08 tl
(EARNED) 631.92 424.08 tl
(\(SEE BACK\)) 321.12 427.68 tl
(\(SEE BACK\)) 415.68 427.68 tl
(\(SEE BACK\)) 510.24 427.68 tl
(CIT.) 300.72 427.92 tl
(TARDY) 360.72 427.92 tl
(CIT.) 395.28 427.92 tl
(TARDY) 455.04 427.92 tl
(CIT.) 489.84 427.92 tl
(TARDY) 549.6 427.92 tl
(CIT.) 605.52 427.92 tl
(TARDY) 711.6 427.92 tl
[8 0 0 -8 0 0] /Helvetica-Narrow ssf
270 (PERIOD) 52.56 118.56 lrot
270 (PERIOD) 745.44 118.56 lrot
270 (PERIOD) 52.56 422.4 lrot
270 (PERIOD) 745.44 422.4 lrot
/#copies 1 def
%%PageFonts: Courier Helvetica-Narrow Helvetica-Narrow-Bold Helvetica-Bold
showpage
%%Trailer
%%Pages: 1
%%DocumentFonts: Courier Helvetica-Narrow Helvetica-Narrow-Bold Helvetica-Bold
%%BoundingBox: 0 0 792 612


View file

@ -0,0 +1,91 @@
%!
%% Elizabeth D. Zwicky
%% zwicky@erg.sri.com
%% multiflake
/newflake
{/seed usertime def
seed srand
/strokecolor [rand 99 mod 100 div
rand 99 mod 100 div
100 rand 22 mod sub 100 div] def
/fillcolor [rand 99 mod 100 div
100 rand 22 mod sub 100 div
rand 99 mod 100 div] def
/eofillcolor [rand 99 mod 100 div
rand 22 mod 100 div
100 rand 22 mod sub 100 div] def
/colorfill {fillcolor aload pop setrgbcolor fill } def
/colorstroke {strokecolor aload pop setrgbcolor stroke } def
/eocolorfill {eofillcolor aload pop setrgbcolor eofill } def
/arm {0 0 moveto
5 {3 {x y x y x y curveto} repeat} repeat
seed srand
0 0 moveto
5 {3 {x neg y x neg y x neg y curveto} repeat} repeat
seed srand
} def
newpath
0 0 moveto boxsize 0 rlineto 0 boxsize rlineto boxsize neg 0 rlineto
0 0 lineto
rand 99 mod 100 div
100 rand 22 mod sub 100 div
100 rand 22 mod sub 100 div
sethsbcolor fill
seed srand
boxsize 2 div boxsize 2 div translate
%% If the device you are using can handle complex fills, replace the
%% next three lines with:
%%
6 {arm 60 rotate} repeat
gsave colorfill grestore gsave eocolorfill grestore colorstroke
%%
%% This will be not only faster, but prettier. On a LaserWriter or a
%% Tektronix Phaser II PS it gives a limitcheck.
%% 6 {arm 60 rotate colorfill} repeat
%% 6 {arm 60 rotate eocolorfill} repeat
%% 6 {arm 60 rotate} repeat colorstroke
} def
1 setlinewidth
clippath [pathbbox]== pathbbox /ury exch def /urx exch def /lly exch def /llx exch def
/minsize 250 def
/pagewidth urx llx sub def
/pageheight ury lly sub def
/inwidth pagewidth minsize div def
/inheight pageheight minsize div def
/boxsize
inwidth inheight gt
{pagewidth inwidth truncate div}
{pageheight inheight truncate div}
ifelse
def
/inwidth pagewidth boxsize div cvi def
/inheight pageheight boxsize div cvi def
/x {rand 70 mod abs} def
/y {rand 120 mod abs} def
llx lly translate
inheight dup == {
inwidth {
gsave
(NEWFLAKE)==
newflake
grestore
boxsize 0 translate
} repeat
boxsize inwidth mul neg boxsize translate
} repeat
showpage

View file

@ -0,0 +1,50 @@
%!
% Example of rotation... draws 36 lines in a circular pattern
/box {
newpath
moveto
72 0 rlineto
0 72 rlineto
-72 0 rlineto
closepath
} def
% Specify font for text labels
/Helvetica findfont 40 scalefont setfont
gsave
40 40 translate % Set origin to (40, 40)
0 0 box stroke % Draw box at new origin...
77 0 moveto
(Translated) show % and label
grestore
gsave
100 150 translate % Translate origin to (100, 150)
30 rotate % Rotate counter-clockwise by 30 degrees
0 0 box stroke % Draw box...
75 0 moveto
(Translated & Rotated) show % and label
grestore
gsave
40 300 translate % Translate to (40, 300)
0.5 1 scale % Reduce x coord by 1/2, y coord left alone
0 0 box stroke % Draw box...
75 0 moveto
(Translated & Squished) show % and label
grestore
gsave
300 300 translate % Set origin to (300, 300)
45 rotate % Rotate coordinates by 45 degrees
0.5 1 scale % Scale coordinates
0 0 box stroke % Draw box
75 0 moveto
(Everything) show
grestore
showpage

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff