Merge pull request #66 from stanim/filename
Use filenames in examples of README
This commit is contained in:
commit
88ee58870c
4 changed files with 51 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
draw2d
|
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)
|
[![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()
|
gc.FillStroke()
|
||||||
|
|
||||||
// Save to file
|
// 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:
|
The same Go code can also generate a pdf document with package draw2dpdf:
|
||||||
|
@ -69,7 +69,7 @@ gc.Close()
|
||||||
gc.FillStroke()
|
gc.FillStroke()
|
||||||
|
|
||||||
// Save to file
|
// 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
|
There are more examples here: https://github.com/llgcode/draw2d/tree/master/samples
|
||||||
|
@ -111,3 +111,4 @@ References
|
||||||
|
|
||||||
- [antigrain.com](http://www.antigrain.com)
|
- [antigrain.com](http://www.antigrain.com)
|
||||||
- [freetype-go](http://code.google.com/p/freetype-go)
|
- [freetype-go](http://code.google.com/p/freetype-go)
|
||||||
|
-
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
// gc.FillStroke()
|
// gc.FillStroke()
|
||||||
//
|
//
|
||||||
// // Save to file
|
// // Save to file
|
||||||
// draw2d.SaveToPngFile(fn, dest)
|
// draw2d.SaveToPngFile("hello.png", dest)
|
||||||
//
|
//
|
||||||
// There are more examples here:
|
// There are more examples here:
|
||||||
// https://github.com/llgcode/draw2d/tree/master/samples
|
// https://github.com/llgcode/draw2d/tree/master/samples
|
||||||
|
|
42
draw2dpdf/README.md
Normal file
42
draw2dpdf/README.md
Normal file
|
@ -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
|
|
@ -2,7 +2,7 @@
|
||||||
// created: 26/06/2015 by Stani Michiels
|
// created: 26/06/2015 by Stani Michiels
|
||||||
|
|
||||||
// Package draw2dpdf provides a graphic context that can draw vector
|
// 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
|
// Quick Start
|
||||||
//
|
//
|
||||||
|
@ -25,11 +25,13 @@
|
||||||
// gc.FillStroke()
|
// gc.FillStroke()
|
||||||
//
|
//
|
||||||
// // Save to file
|
// // Save to file
|
||||||
// draw2dpdf.SaveToPdfFile(fn, dest)
|
// draw2dpdf.SaveToPdfFile("hello.pdf", dest)
|
||||||
//
|
//
|
||||||
// There are more examples here:
|
// There are more examples here:
|
||||||
// https://github.com/llgcode/draw2d/tree/master/samples
|
// https://github.com/llgcode/draw2d/tree/master/samples
|
||||||
//
|
//
|
||||||
|
// Alternative backends
|
||||||
|
//
|
||||||
// Drawing on images is provided by the draw2d package.
|
// Drawing on images is provided by the draw2d package.
|
||||||
// Drawing on opengl is provided by the draw2dgl package.
|
// Drawing on opengl is provided by the draw2dgl package.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue