Change getting started in Readme and godoc
This commit is contained in:
parent
d6d74f19f9
commit
56180d8101
4 changed files with 75 additions and 45 deletions
19
README.md
19
README.md
|
@ -38,6 +38,15 @@ Quick Start
|
|||
The following Go code generates a simple drawing and saves it to an image file with package draw2d:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/llgcode/draw2d/draw2dimg"
|
||||
"image"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Initialize the graphic context on an RGBA image
|
||||
dest := image.NewRGBA(image.Rect(0, 0, 297, 210.0))
|
||||
gc := draw2dimg.NewGraphicContext(dest)
|
||||
|
@ -56,11 +65,20 @@ gc.FillStroke()
|
|||
|
||||
// Save to file
|
||||
draw2dimg.SaveToPngFile("hello.png", dest)
|
||||
}
|
||||
```
|
||||
|
||||
The same Go code can also generate a pdf document with package draw2dpdf:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/llgcode/draw2d/draw2dpdf"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Initialize the graphic context on an RGBA image
|
||||
dest := draw2dpdf.NewPdf("L", "mm", "A4")
|
||||
gc := draw2dpdf.NewGraphicContext(dest)
|
||||
|
@ -79,6 +97,7 @@ gc.FillStroke()
|
|||
|
||||
// Save to file
|
||||
draw2dpdf.SaveToPdfFile("hello.pdf", dest)
|
||||
}
|
||||
```
|
||||
|
||||
There are more examples here: https://github.com/llgcode/draw2d/tree/master/samples
|
||||
|
|
13
draw2d.go
13
draw2d.go
|
@ -26,6 +26,15 @@
|
|||
// Package draw2d itself provides a graphic context that can draw vector
|
||||
// graphics and text on an image canvas. The following Go code
|
||||
// generates a simple drawing and saves it to an image file:
|
||||
// package main
|
||||
//
|
||||
// import (
|
||||
// "github.com/llgcode/draw2d/draw2dimg"
|
||||
// "image"
|
||||
// "image/color"
|
||||
// )
|
||||
//
|
||||
// func main() {
|
||||
// // Initialize the graphic context on an RGBA image
|
||||
// dest := image.NewRGBA(image.Rect(0, 0, 297, 210.0))
|
||||
// gc := draw2dimg.NewGraphicContext(dest)
|
||||
|
@ -43,7 +52,9 @@
|
|||
// gc.FillStroke()
|
||||
//
|
||||
// // Save to file
|
||||
// draw2d.SaveToPngFile("hello.png", dest)
|
||||
// draw2dimg.SaveToPngFile("hello.png", dest)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// There are more examples here:
|
||||
// https://github.com/llgcode/draw2d/tree/master/samples
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Binary file not shown.
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
Loading…
Reference in a new issue