From f24cc0d0ec567331b3cdc8b8b03afea63e56cbda Mon Sep 17 00:00:00 2001 From: Stani Date: Fri, 10 Jul 2015 02:14:48 +0200 Subject: [PATCH] add sample: line --- samples/line/line.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 samples/line/line.go diff --git a/samples/line/line.go b/samples/line/line.go new file mode 100644 index 0000000..7331cd5 --- /dev/null +++ b/samples/line/line.go @@ -0,0 +1,30 @@ +// Copyright 2010 The draw2d Authors. All rights reserved. +// created: 21/11/2010 by Laurent Le Goff, Stani Michiels + +// Package line draws vertically spaced lines. +package line + +import ( + "github.com/llgcode/draw2d" + "github.com/llgcode/draw2d/samples" +) + +// Main draws vertically spaced lines and returns the filename. +// This should only be used during testing. +func Main(gc draw2d.GraphicContext, ext string) (string, error) { + // Draw the line + for x := 5.0; x < 297; x += 10 { + Draw(gc, x, 0, x, 210) + } + + // Return the output filename + return samples.Output("line", ext), nil +} + +// Draw vertically spaced lines +func Draw(gc draw2d.GraphicContext, x0, y0, x1, y1 float64) { + // Draw a line + gc.MoveTo(x0, y0) + gc.LineTo(x1, y1) + gc.Stroke() +}