Clean up for go1

This commit is contained in:
Laurent Le Goff 2012-03-29 16:52:12 +02:00
parent c595982fba
commit 7f2c247e7a
38 changed files with 65 additions and 63 deletions

View file

@ -4,23 +4,23 @@
all: install
install:
cd draw2d && make install
cd draw2d && go install
# cd draw2dgl && make install
cd postscript && make install
cd postscript && go install
# cd wingui && make install
clean:
cd draw2d && make clean
# cd draw2dgl && make clean
cd postscript && make clean
cd cmd && make clean
# cd wingui && make clean
build:
cd draw2d && go build
# cd draw2dgl && make build
cd postscript && go build
# cd wingui && make build
nuke:
cd draw2d && make nuke
# cd draw2dgl && make nuke
cd postscript && make nuke
# cd wingui && make nuke
clean:
cd draw2d && go clean
# cd draw2dgl && make clean
cd postscript && go clean
cd cmd && go clean
# cd wingui && make clean
command:
cd cmd && make

View file

@ -5,7 +5,6 @@ import (
"fmt"
"log"
"os"
"time"
"code.google.com/p/draw2d/draw2d"
"image"
@ -26,7 +25,6 @@ var (
func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
i := image.NewRGBA(image.Rect(0, 0, w, h))
gc := draw2d.NewGraphicContext(i)
lastTime = time.Now()
gc.SetStrokeColor(image.Black)
gc.SetFillColor(image.White)
@ -37,8 +35,6 @@ func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
}
func saveToPngFile(TestName string, m image.Image) {
dt := time.Now().Sub(lastTime)
fmt.Printf("%s during: %f ms\n", TestName, float64(dt)*1e-6)
filePath := folder + TestName + ".png"
f, err := os.Create(filePath)
if err != nil {

View file

@ -8,7 +8,6 @@ import (
"fmt"
"log"
"os"
"time"
"code.google.com/p/draw2d/draw2d"
"image"
@ -29,7 +28,6 @@ var (
func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
i := image.NewRGBA(image.Rect(0, 0, w, h))
gc := draw2d.NewGraphicContext(i)
lastTime = time.Now()
gc.SetStrokeColor(image.Black)
gc.SetFillColor(image.White)
@ -40,9 +38,6 @@ func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
}
func saveToPngFile(TestName string, m image.Image) {
t := time.Now()
dt := t.Sub(lastTime)
fmt.Printf("%s during: %f ms\n", TestName, float64(dt)*1e-6)
filePath := folder + TestName + ".png"
f, err := os.Create(filePath)
if err != nil {
@ -61,8 +56,7 @@ func saveToPngFile(TestName string, m image.Image) {
log.Println(err)
os.Exit(1)
}
dt = time.Now().Sub(t)
fmt.Printf("Wrote %s OK in %f ms.\n", filePath, float64(dt)*1e-6)
fmt.Printf("Wrote %s OK.\n", filePath)
}
/*
@ -513,7 +507,6 @@ func TestBigPicture() {
}
func main() {
t := time.Now()
TestPath()
TestDrawArc()
TestDrawArcNegative()
@ -532,6 +525,4 @@ func main() {
TestPathTransform()
TestFillString()
TestBigPicture()
dt := time.Now().Sub(t)
fmt.Printf("All tests during: %f ms\n", float64(dt)*1e-6)
}

View file

@ -6,7 +6,6 @@ import (
"log"
"math"
"os"
"time"
"code.google.com/p/draw2d/draw2d"
"image"
@ -26,7 +25,6 @@ var (
func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
i := image.NewRGBA(image.Rect(0, 0, w, h))
gc := draw2d.NewGraphicContext(i)
lastTime = time.Now()
gc.SetStrokeColor(image.Black)
gc.SetFillColor(image.White)
@ -37,8 +35,6 @@ func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
}
func saveToPngFile(TestName string, m image.Image) {
dt := time.Now().Sub(lastTime)
fmt.Printf("%s during: %f ms\n", TestName, float64(dt)*1e-6)
filePath := folder + TestName + ".png"
f, err := os.Create(filePath)
if err != nil {

View file

@ -10,7 +10,6 @@ import (
"log"
"math"
"os"
"time"
)
func saveToPngFile(filePath string, m image.Image) {
@ -37,7 +36,7 @@ func saveToPngFile(filePath string, m image.Image) {
func loadFromPngFile(filePath string) image.Image {
f, err := os.OpenFile(filePath, 0, 0)
if f == nil {
log.Printf("can't open file; err=%s\n", err.String())
log.Printf("can't open file; err=%s\n", err)
return nil
}
defer f.Close()
@ -61,9 +60,6 @@ func main() {
//tr.Scale(3, 3)
tr.Translate(-width/2, -height/2)
tr.Translate(200, 5)
lastTime := time.Now()
draw2d.DrawImage(source, dest, tr, draw.Over, draw2d.BilinearFilter)
dt := time.Now().Sub(lastTime)
fmt.Printf("Draw image: %f ms\n", float64(dt)*1e-6)
saveToPngFile("../resource/result/TestDrawImage.png", dest)
}

View file

@ -11,7 +11,6 @@ import (
"log"
"os"
"strings"
"time"
)
func saveToPngFile(filePath string, m image.Image) {
@ -49,9 +48,6 @@ func main() {
bytes, err := ioutil.ReadAll(src)
reader := strings.NewReader(string(bytes))
interpreter := postscript.NewInterpreter(gc)
lastTime := time.Now()
interpreter.Execute(reader)
dt := time.Now().Sub(lastTime)
fmt.Printf("Draw image: %f ms\n", float64(dt)*1e-6)
saveToPngFile("../resource/result/TestPostscript.png", i)
}

View file

@ -6,10 +6,8 @@ import (
"math"
)
//high level path creation
func Rect(path Path, x1, y1, x2, y2 float64) {
path.MoveTo(x1, y1)
path.LineTo(x2, y1)

View file

@ -1,3 +1,2 @@
// The package draw2d provide a Graphic Context that can draw vectorial figure on surface.
package draw2d

View file

@ -1,6 +1,7 @@
// Copyright 2010 The draw2d Authors. All rights reserved.
// created: 21/11/2010 by Laurent Le Goff
package draw2d
/*
import (
"image/draw"
@ -9,6 +10,7 @@ import (
)*/
const M = 1<<16 - 1
/*
type NRGBAPainter struct {
// The image to compose onto.

View file

@ -26,7 +26,6 @@ func (c *PathConverter) Convert(paths ...*PathStorage) {
}
}
func (c *PathConverter) ConvertCommand(cmd PathCmd, vertices ...float64) int {
switch cmd {
case MoveTo:

View file

@ -12,7 +12,6 @@ const (
type Polygon []float64
type PolygonEdge struct {
X, Slope float64
FirstLine, LastLine int
@ -166,7 +165,6 @@ func (p Polygon) getEdges(startIndex, vertexCount int, edges []PolygonEdge, tr [
return edgeCount
}
//! Creates a polygon edge between two vectors.
/*! Clips the edge vertically to the clip rectangle. Returns true for edges that
* should be rendered, false for others.
@ -228,7 +226,6 @@ func getEdge(x0, y0, x1, y1 float64, edge *PolygonEdge, clipBound [4]float64) bo
return true
}
//! Creates a vertical polygon edge between two y values.
/*! Clips the edge vertically to the clip rectangle. Returns true for edges that
* should be rendered, false for others.
@ -277,12 +274,12 @@ func getVerticalEdge(startY, endY, x float64, edge *PolygonEdge, clipBound [4]fl
return true
}
type VertexData struct {
X, Y float64
ClipFlags int
Line int
}
//! Calculates the edges of the polygon with transformation and clipping to edges array.
/*! Note that this may return upto three times the amount of edges that the polygon has vertices,
* in the unlucky case where both left and right side get clipped for all edges.

View file

@ -18,7 +18,6 @@ const (
MiterJoin
)
type LineStroker struct {
Next VertexConverter
HalfLineWidth float64
@ -42,7 +41,6 @@ func NewLineStroker(c Cap, j Join, converter VertexConverter) *LineStroker {
return l
}
func (l *LineStroker) NextCommand(command VertexCommand) {
l.command = command
if command == VertexStopCommand {
@ -107,7 +105,6 @@ func (l *LineStroker) closePolygon() {
}
}
func (l *LineStroker) line(x1, y1, x2, y2 float64) {
dx := (x2 - x1)
dy := (y2 - y1)

View file

@ -17,7 +17,6 @@ func (o *PrimitiveOperator) Execute(interpreter *Interpreter) {
o.f(interpreter)
}
func save(interpreter *Interpreter) {
interpreter.Push("VM Snapshot")
}
@ -26,7 +25,6 @@ func restore(interpreter *Interpreter) {
interpreter.Pop()
}
func initSystemOperators(interpreter *Interpreter) {
interpreter.SystemDefine("save", NewOperator(save))
interpreter.SystemDefine("restore", NewOperator(restore))

View file

@ -3,22 +3,25 @@
package postscript
import ()
//int array array -> Create array of length int
func array(interpreter *Interpreter) {
interpreter.Push(make([]Value, interpreter.PopInt()))
}
//array length int -> Return number of elements in array
func lengtharray(interpreter *Interpreter) {
interpreter.Push(float64(len(interpreter.Pop().([]Value))))
}
//array index get any -> Return array element indexed by index
func getarray(interpreter *Interpreter) {
index := interpreter.PopInt()
array := interpreter.Pop().([]Value)
interpreter.Push(array[index])
}
//array index any put -> Put any into array at index
func putarray(interpreter *Interpreter) {
value := interpreter.Pop()
@ -26,6 +29,7 @@ func putarray(interpreter *Interpreter) {
array := interpreter.Pop().([]Value)
array[index] = value
}
//array index count getinterval subarray -> Return subarray of array starting at index for count elements
func getinterval(interpreter *Interpreter) {
count := interpreter.PopInt()
@ -35,6 +39,7 @@ func getinterval(interpreter *Interpreter) {
copy(subarray, array[index:index+count])
interpreter.Push(subarray)
}
//array1 index array2 putinterval Replace subarray of array1 starting at index by array2|packedarray2
func putinterval(interpreter *Interpreter) {
array2 := interpreter.Pop().([]Value)
@ -44,6 +49,7 @@ func putinterval(interpreter *Interpreter) {
array1[i+index] = v
}
}
// any0 … anyn1 array astore array
// stores the objects any0 to anyn1 from the operand stack into array, where n is the length of array
func astore(interpreter *Interpreter) {
@ -53,6 +59,7 @@ func astore(interpreter *Interpreter) {
array[i] = interpreter.Pop()
}
}
//array aload any0 … any-1 array
//Push all elements of array on stack
func aload(interpreter *Interpreter) {
@ -62,6 +69,7 @@ func aload(interpreter *Interpreter) {
}
interpreter.Push(array)
}
//array proc forall Execute proc for each element of array
func forallarray(interpreter *Interpreter) {
proc := NewProcedure(interpreter.PopProcedureDefinition())

View file

@ -6,6 +6,7 @@ package postscript
import (
"log"
)
// any exec Execute arbitrary object
func exec(interpreter *Interpreter) {
value := interpreter.Pop()
@ -69,7 +70,6 @@ func stopped(interpreter *Interpreter) {
interpreter.Push(false)
}
func initControlOperators(interpreter *Interpreter) {
interpreter.SystemDefine("exec", NewOperator(exec))
interpreter.SystemDefine("if", NewOperator(ifoperator))

View file

@ -3,32 +3,37 @@
package postscript
import (
"log"
)
//int dict dict -> Create dictionary with capacity for int elements
func dict(interpreter *Interpreter) {
interpreter.Push(NewDictionary(interpreter.PopInt()))
}
//dict length int -> Return number of entries in dict
func lengthdict(interpreter *Interpreter) {
dictionary := interpreter.Pop().(Dictionary)
interpreter.Push(float64(len(dictionary)))
}
//dict maxlength int -> Return current capacity of dict
func maxlength(interpreter *Interpreter) {
interpreter.Pop()
interpreter.Push(float64(999999999)) // push arbitrary value
}
//dict begin -> Push dict on dictionary stack
func begin(interpreter *Interpreter) {
interpreter.PushDictionary(interpreter.Pop().(Dictionary))
}
// end -> Pop current dictionary off dictionary stack
func end(interpreter *Interpreter) {
interpreter.PopDictionary()
}
//key value def -> Associate key and value in current dictionary
func def(interpreter *Interpreter) {
value := interpreter.Pop()
@ -38,6 +43,7 @@ func def(interpreter *Interpreter) {
}
interpreter.Define(name, value)
}
//key load value -> Search dictionary stack for key and return associated value
func load(interpreter *Interpreter) {
name := interpreter.PopName()
@ -47,6 +53,7 @@ func load(interpreter *Interpreter) {
}
interpreter.Push(value)
}
//key value store -> Replace topmost definition of key
func store(interpreter *Interpreter) {
value := interpreter.Pop()
@ -56,12 +63,14 @@ func store(interpreter *Interpreter) {
dictionary[key] = value
}
}
//dict key get any -> Return value associated with key in dict
func getdict(interpreter *Interpreter) {
key := interpreter.PopName()
dictionary := interpreter.Pop().(Dictionary)
interpreter.Push(dictionary[key])
}
//dict key value put -> Associate key with value in dict
func putdict(interpreter *Interpreter) {
value := interpreter.Pop()
@ -69,18 +78,21 @@ func putdict(interpreter *Interpreter) {
dictionary := interpreter.Pop().(Dictionary)
dictionary[key] = value
}
//dict key undef Remove key and its value from dict
func undef(interpreter *Interpreter) {
key := interpreter.PopName()
dictionary := interpreter.Pop().(Dictionary)
dictionary[key] = nil
}
//dict key known bool -> Test whether key is in dict
func known(interpreter *Interpreter) {
key := interpreter.PopName()
dictionary := interpreter.Pop().(Dictionary)
interpreter.Push(dictionary[key] != nil)
}
//key where (dict true) or false -> Find dictionary in which key is defined
func where(interpreter *Interpreter) {
key := interpreter.PopName()
@ -92,6 +104,7 @@ func where(interpreter *Interpreter) {
interpreter.Push(true)
}
}
// dict1 dict2 copy dict2 -> Copy contents of dict1 to dict2
func copydict(interpreter *Interpreter) {
dict2 := interpreter.Pop().(Dictionary)
@ -101,6 +114,7 @@ func copydict(interpreter *Interpreter) {
}
interpreter.Push(dict2)
}
//dict proc forall -> Execute proc for each entry in dict
func foralldict(interpreter *Interpreter) {
proc := NewProcedure(interpreter.PopProcedureDefinition())
@ -111,34 +125,42 @@ func foralldict(interpreter *Interpreter) {
proc.Execute(interpreter)
}
}
// currentdict dict -> Return current dictionary
func currentdict(interpreter *Interpreter) {
interpreter.Push(interpreter.PeekDictionary())
}
// systemdict dict -> Return system dictionary
func systemdict(interpreter *Interpreter) {
interpreter.Push(interpreter.SystemDictionary())
}
// userdict dict -> Return writeable dictionary in local VM
func userdict(interpreter *Interpreter) {
interpreter.Push(interpreter.UserDictionary())
}
// globaldict dict -> Return writeable dictionary in global VM
func globaldict(interpreter *Interpreter) {
interpreter.Push(interpreter.UserDictionary())
}
// statusdict dict -> Return product-dependent dictionary
func statusdict(interpreter *Interpreter) {
interpreter.Push(interpreter.UserDictionary())
}
// countdictstack int -> Count elements on dictionary stack
func countdictstack(interpreter *Interpreter) {
interpreter.Push(float64(interpreter.DictionaryStackSize()))
}
//array dictstack subarray -> Copy dictionary stack into array
func dictstack(interpreter *Interpreter) {
panic("No yet implemenented")
}
// cleardictstack -> Pop all nonpermanent dictionaries off dictionary stack
func cleardictstack(interpreter *Interpreter) {
interpreter.ClearDictionaries()

View file

@ -3,7 +3,6 @@
package postscript
func eq(interpreter *Interpreter) {
value1 := interpreter.Pop()
value2 := interpreter.Pop()

View file

@ -8,6 +8,7 @@ package postscript
func pop(interpreter *Interpreter) {
interpreter.Pop()
}
//any1 any2 exch any2 any1 -> Exchange top two elements
func exch(interpreter *Interpreter) {
value1 := interpreter.Pop()
@ -15,6 +16,7 @@ func exch(interpreter *Interpreter) {
interpreter.Push(value1)
interpreter.Push(value2)
}
//any dup any any -> Duplicate top element
func dup(interpreter *Interpreter) {
interpreter.Push(interpreter.Peek())
@ -28,11 +30,13 @@ func copystack(interpreter *Interpreter) {
interpreter.Push(value)
}
}
//anyn … any0 n index anyn … any0 anyn -> Duplicate arbitrary element
func index(interpreter *Interpreter) {
f := interpreter.PopInt()
interpreter.Push(interpreter.Get(int(f)))
}
//anyn1 … any0 n j roll any(j1) mod n … any0 anyn1 … anyj mod n -> Roll n elements up j times
func roll(interpreter *Interpreter) {
j := interpreter.PopInt()
@ -43,20 +47,25 @@ func roll(interpreter *Interpreter) {
interpreter.Push(values[(n+i-j)%n])
}
}
//any1 … anyn clear -> Discard all elements
func clear(interpreter *Interpreter) {
interpreter.ClearOperands()
}
//any1 … anyn count any1 … anyn n -> Count elements on stack
func count(interpreter *Interpreter) {
interpreter.Push(interpreter.OperandSize())
}
//Mark
type Mark struct{}
// mark mark -> Push mark on stack
func mark(interpreter *Interpreter) {
interpreter.Push(Mark{})
}
//mark obj 1 … obj n cleartomark -> Discard elements down through mark
func cleartomark(interpreter *Interpreter) {
value := interpreter.Pop()
@ -64,6 +73,7 @@ func cleartomark(interpreter *Interpreter) {
value = interpreter.Pop()
}
}
//mark obj 1 … obj n counttomark mark obj 1 … obj n n -> Count elements down to mark
func counttomark(interpreter *Interpreter) {
i := 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

@ -4,13 +4,12 @@
package wingui
import (
"syscall"
"unsafe"
"fmt"
"os"
"syscall"
"unsafe"
)
func abortf(format string, a ...interface{}) {
fmt.Fprintf(os.Stdout, format, a...)
os.Exit(1)

View file

@ -1,6 +1,5 @@
package wingui
import "unsafe"
import "syscall"