From 153a3875fa3c5cdae784b020c85e4e39fd6b2b82 Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Sat, 20 Feb 2016 23:22:00 -0500 Subject: [PATCH] cubic example --- examples/cubic.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 examples/cubic.go diff --git a/examples/cubic.go b/examples/cubic.go new file mode 100644 index 0000000..8e81c2b --- /dev/null +++ b/examples/cubic.go @@ -0,0 +1,36 @@ +package main + +import "github.com/fogleman/gg" + +func main() { + const S = 1000 + dc := gg.NewContext(S, S) + dc.SetRGB(1, 1, 1) + dc.Clear() + dc.Translate(S/2, S/2) + dc.Scale(40, 40) + + var x0, y0, x1, y1, x2, y2, x3, y3 float64 + x0, y0 = -10, 0 + x1, y1 = -8, -8 + x2, y2 = 8, 8 + x3, y3 = 10, 0 + + dc.MoveTo(x0, y0) + dc.CubicTo(x1, y1, x2, y2, x3, y3) + dc.SetRGBA(0, 0, 0, 0.2) + dc.SetLineWidth(10) + dc.FillPreserve() + dc.SetRGB(0, 0, 0) + dc.Stroke() + + dc.MoveTo(x0, y0) + dc.LineTo(x1, y1) + dc.LineTo(x2, y2) + dc.LineTo(x3, y3) + dc.SetRGBA(1, 0, 0, 0.4) + dc.SetLineWidth(2) + dc.Stroke() + + dc.SavePNG("out.png") +}