summaryrefslogtreecommitdiff
path: root/vendor/github.com/fogleman/gg/examples
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/fogleman/gg/examples')
-rw-r--r--vendor/github.com/fogleman/gg/examples/gradient-linear.go39
-rw-r--r--vendor/github.com/fogleman/gg/examples/gradient-radial.go27
-rw-r--r--vendor/github.com/fogleman/gg/examples/pattern-fill.go20
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")
+}