2015-07-10 00:14:48 +00:00
|
|
|
// 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 (
|
2015-07-10 19:50:07 +00:00
|
|
|
"image/color"
|
|
|
|
|
2018-11-16 11:21:14 +00:00
|
|
|
"git.fromouter.space/crunchy-rocks/draw2d"
|
|
|
|
"git.fromouter.space/crunchy-rocks/draw2d/draw2dkit"
|
|
|
|
"git.fromouter.space/crunchy-rocks/draw2d/samples"
|
2015-07-10 00:14:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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) {
|
2015-07-10 19:50:07 +00:00
|
|
|
gc.SetFillRule(draw2d.FillRuleWinding)
|
|
|
|
gc.Clear()
|
2015-07-10 00:14:48 +00:00
|
|
|
// Draw the line
|
|
|
|
for x := 5.0; x < 297; x += 10 {
|
|
|
|
Draw(gc, x, 0, x, 210)
|
|
|
|
}
|
2015-07-10 19:50:07 +00:00
|
|
|
gc.ClearRect(100, 75, 197, 135)
|
2015-08-14 19:40:32 +00:00
|
|
|
draw2dkit.Ellipse(gc, 148.5, 105, 35, 25)
|
2015-07-10 19:50:07 +00:00
|
|
|
gc.SetFillColor(color.RGBA{0xff, 0xff, 0x44, 0xff})
|
|
|
|
gc.FillStroke()
|
2015-07-10 00:14:48 +00:00
|
|
|
|
|
|
|
// 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()
|
|
|
|
}
|