diff --git a/README.md b/README.md index 31b1091..21c2d94 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ draw2d ====== -Package draw2d is a pure [go](http://golang.org) 2D vector graphics library with support for multiple output devices such as [images](http://golang.org/pkg/image) (draw2d), pdf documents (draw2dpdf) and opengl (draw2dopengl), which can also be used on the google app engine. It can be used as a pure go [Cairo](http://www.cairographics.org/) alternative. draw2d is released under the BSD license. See the [documentation](http://godoc.org/github.com/llgcode/draw2d) for more details. +Package draw2d is a pure [go](http://golang.org) 2D vector graphics library with support for multiple output devices such as [images](http://golang.org/pkg/image) (draw2d), pdf documents (draw2dpdf) and opengl (draw2dgl), which can also be used on the google app engine. It can be used as a pure go [Cairo](http://www.cairographics.org/) alternative. draw2d is released under the BSD license. See the [documentation](http://godoc.org/github.com/llgcode/draw2d) for more details. [![geometry](https://raw.githubusercontent.com/llgcode/draw2d/master/output/samples/geometry.png)](https://raw.githubusercontent.com/llgcode/draw2d/master/resource/image/geometry.pdf)[![postscript](https://raw.githubusercontent.com/llgcode/draw2d/master/output/samples/postscript.png)](https://raw.githubusercontent.com/llgcode/draw2d/master/resource/image/postscript.pdf) @@ -46,7 +46,7 @@ gc.Close() gc.FillStroke() // Save to file -draw2d.SaveToPngFile(fn, dest) +draw2d.SaveToPngFile("hello.png", dest) ``` The same Go code can also generate a pdf document with package draw2dpdf: @@ -69,7 +69,7 @@ gc.Close() gc.FillStroke() // Save to file -draw2dpdf.SaveToPdfFile(fn, dest) +draw2dpdf.SaveToPdfFile("hello.pdf", dest) ``` There are more examples here: https://github.com/llgcode/draw2d/tree/master/samples @@ -111,3 +111,4 @@ References - [antigrain.com](http://www.antigrain.com) - [freetype-go](http://code.google.com/p/freetype-go) + - diff --git a/draw2d.go b/draw2d.go index a547c28..9e6a731 100644 --- a/draw2d.go +++ b/draw2d.go @@ -43,7 +43,7 @@ // gc.FillStroke() // // // Save to file -// draw2d.SaveToPngFile(fn, dest) +// draw2d.SaveToPngFile("hello.png", dest) // // There are more examples here: // https://github.com/llgcode/draw2d/tree/master/samples diff --git a/draw2dpdf/README.md b/draw2dpdf/README.md new file mode 100644 index 0000000..6ac7e99 --- /dev/null +++ b/draw2dpdf/README.md @@ -0,0 +1,42 @@ +draw2d pdf +========== + +Package draw2dpdf provides a graphic context that can draw vector graphics and text on pdf file with the [gofpdf](https://github.com/jung-kurt/gofpdf) package. + +Quick Start +----------- + +The following Go code generates a simple drawing and saves it to a pdf document: +```go +// Initialize the graphic context on an RGBA image +dest := draw2dpdf.NewPdf("L", "mm", "A4") +gc := draw2d.NewGraphicContext(dest) + +// Set some properties +gc.SetFillColor(color.RGBA{0x44, 0xff, 0x44, 0xff}) +gc.SetStrokeColor(color.RGBA{0x44, 0x44, 0x44, 0xff}) +gc.SetLineWidth(5) + +// Draw a closed shape +gc.MoveTo(10, 10) // should always be called first for a new path +gc.LineTo(100, 50) +gc.QuadCurveTo(100, 10, 10, 10) +gc.Close() +gc.FillStroke() + +// Save to file +draw2dpdf.SaveToPdfFile("hello.pdf", dest) +``` + +There are more examples here: https://github.com/llgcode/draw2d/tree/master/samples + +Alternative backends +-------------------- + +- Drawing on images is provided by the draw2d package. +- Drawing on opengl is provided by the draw2dgl package. + +Acknowledgments +--------------- + +The pdf backend uses https://github.com/jung-kurt/gofpdf \ No newline at end of file diff --git a/draw2dpdf/doc.go b/draw2dpdf/doc.go index 846f336..922099c 100644 --- a/draw2dpdf/doc.go +++ b/draw2dpdf/doc.go @@ -2,7 +2,7 @@ // created: 26/06/2015 by Stani Michiels // Package draw2dpdf provides a graphic context that can draw vector -// graphics and text on pdf file. +// graphics and text on pdf file with the gofpdf package. // // Quick Start // @@ -25,11 +25,13 @@ // gc.FillStroke() // // // Save to file -// draw2dpdf.SaveToPdfFile(fn, dest) +// draw2dpdf.SaveToPdfFile("hello.pdf", dest) // // There are more examples here: // https://github.com/llgcode/draw2d/tree/master/samples // +// Alternative backends +// // Drawing on images is provided by the draw2d package. // Drawing on opengl is provided by the draw2dgl package. //