Пример #1
0
func (h *spaceFillingImage) drawSnake(gc draw2d.GraphicContext, snake *draw2d.Path) {
	gc.SetStrokeColor(h.SnakeColor)
	gc.SetLineCap(draw2d.SquareCap)
	gc.SetLineJoin(draw2d.MiterJoin)
	gc.SetLineWidth(2)

	gc.Stroke(snake)
}
Пример #2
0
// Dash draws a line with a dash pattern
func Dash(gc draw2d.GraphicContext, x, y, width, height float64) {
	sx, sy := width/162, height/205
	gc.SetStrokeColor(image.Black)
	gc.SetLineDash([]float64{height / 10, height / 50, height / 50, height / 50}, -50.0)
	gc.SetLineCap(draw2d.ButtCap)
	gc.SetLineJoin(draw2d.RoundJoin)
	gc.SetLineWidth(height / 50)

	gc.MoveTo(x+sx*60.0, y)
	gc.LineTo(x+sx*60.0, y)
	gc.LineTo(x+sx*162, y+sy*205)
	gc.RLineTo(sx*-102.4, 0.0)
	gc.CubicCurveTo(x+sx*-17, y+sy*205, x+sx*-17, y+sy*103, x+sx*60.0, y+sy*103.0)
	gc.Stroke()
	gc.SetLineDash(nil, 0.0)
}
Пример #3
0
// Draw a line with an angle with specified line cap and join
func Draw(gc draw2d.GraphicContext, cap draw2d.Cap, join draw2d.Join,
	x0, y0, x1, y1, offset float64) {
	gc.SetLineCap(cap)
	gc.SetLineJoin(join)

	// Draw thick line
	gc.SetStrokeColor(color.NRGBA{0x33, 0x33, 0x33, 0xFF})
	gc.SetLineWidth(30.0)
	gc.MoveTo(x0, y0)
	gc.LineTo((x0+x1)/2+offset, (y0+y1)/2)
	gc.LineTo(x1, y1)
	gc.Stroke()

	// Draw thin helping line
	gc.SetStrokeColor(color.NRGBA{0xFF, 0x33, 0x33, 0xFF})
	gc.SetLineWidth(2.56)
	gc.MoveTo(x0, y0)
	gc.LineTo((x0+x1)/2+offset, (y0+y1)/2)
	gc.LineTo(x1, y1)
	gc.Stroke()
}