diff options
| author | Felix Hanley <felix@userspace.com.au> | 2017-03-19 15:19:42 +0000 |
|---|---|---|
| committer | Felix Hanley <felix@userspace.com.au> | 2017-03-19 15:19:42 +0000 |
| commit | 8a541d499b6f117cd3a81e475ee779ba60fc0637 (patch) | |
| tree | 7b3b5326235725ab93056b5ff4637d987fb0a7b6 /vendor/github.com/fogleman/gg/examples | |
| parent | fe847b2d01060044274d20d2c35ae01a684d4ee3 (diff) | |
| download | crjw-maps-master.tar.gz crjw-maps-master.tar.bz2 | |
Diffstat (limited to 'vendor/github.com/fogleman/gg/examples')
3 files changed, 86 insertions, 0 deletions
diff --git a/vendor/github.com/fogleman/gg/examples/gradient-linear.go b/vendor/github.com/fogleman/gg/examples/gradient-linear.go new file mode 100644 index 0000000..5f1ceec --- /dev/null +++ b/vendor/github.com/fogleman/gg/examples/gradient-linear.go @@ -0,0 +1,39 @@ +package main + +import ( + "image/color" + + "github.com/fogleman/gg" +) + +func main() { + dc := gg.NewContext(500, 400) + + grad := gg.NewLinearGradient(20, 320, 400, 20) + grad.AddColorStop(0, color.RGBA{0, 255, 0, 255}) + grad.AddColorStop(1, color.RGBA{0, 0, 255, 255}) + grad.AddColorStop(0.5, color.RGBA{255, 0, 0, 255}) + + dc.SetColor(color.White) + dc.DrawRectangle(20, 20, 400-20, 300) + dc.Stroke() + + dc.SetStrokeStyle(grad) + dc.SetLineWidth(4) + dc.MoveTo(10, 10) + dc.LineTo(410, 10) + dc.LineTo(410, 100) + dc.LineTo(10, 100) + dc.ClosePath() + dc.Stroke() + + dc.SetFillStyle(grad) + dc.MoveTo(10, 120) + dc.LineTo(410, 120) + dc.LineTo(410, 300) + dc.LineTo(10, 300) + dc.ClosePath() + dc.Fill() + + dc.SavePNG("out.png") +} diff --git a/vendor/github.com/fogleman/gg/examples/gradient-radial.go b/vendor/github.com/fogleman/gg/examples/gradient-radial.go new file mode 100644 index 0000000..d336135 --- /dev/null +++ b/vendor/github.com/fogleman/gg/examples/gradient-radial.go @@ -0,0 +1,27 @@ +package main + +import ( + "image/color" + + "github.com/fogleman/gg" +) + +func main() { + dc := gg.NewContext(400, 200) + + grad := gg.NewRadialGradient(100, 100, 10, 100, 120, 80) + grad.AddColorStop(0, color.RGBA{0, 255, 0, 255}) + grad.AddColorStop(1, color.RGBA{0, 0, 255, 255}) + + dc.SetFillStyle(grad) + dc.DrawRectangle(0, 0, 200, 200) + dc.Fill() + + dc.SetColor(color.White) + dc.DrawCircle(100, 100, 10) + dc.Stroke() + dc.DrawCircle(100, 120, 80) + dc.Stroke() + + dc.SavePNG("out.png") +} diff --git a/vendor/github.com/fogleman/gg/examples/pattern-fill.go b/vendor/github.com/fogleman/gg/examples/pattern-fill.go new file mode 100644 index 0000000..4500350 --- /dev/null +++ b/vendor/github.com/fogleman/gg/examples/pattern-fill.go @@ -0,0 +1,20 @@ +package main + +import "github.com/fogleman/gg" + +func main() { + im, err := gg.LoadPNG("examples/lenna.png") + if err != nil { + panic(err) + } + pattern := gg.NewSurfacePattern(im, gg.RepeatBoth) + dc := gg.NewContext(600, 600) + dc.MoveTo(20, 20) + dc.LineTo(590, 20) + dc.LineTo(590, 590) + dc.LineTo(20, 590) + dc.ClosePath() + dc.SetFillStyle(pattern) + dc.Fill() + dc.SavePNG("out.png") +} |
