Пример #1
0
func newBox(cvs *canvas.Canvas, r draw.Rectangle) *box {
	var b box
	red := image.Uniform{image.Red}
	b.n = canvas.NewLine(red, r.Min, draw.Pt(r.Max.X, r.Min.Y), 1)
	b.e = canvas.NewLine(red, draw.Pt(r.Max.X, r.Min.Y), r.Max, 1)
	b.s = canvas.NewLine(red, r.Max, draw.Pt(r.Min.X, r.Max.Y), 1)
	b.w = canvas.NewLine(red, draw.Pt(r.Min.X, r.Max.Y), r.Min, 1)
	cvs.AddItem(b.n)
	cvs.AddItem(b.e)
	cvs.AddItem(b.s)
	cvs.AddItem(b.w)
	return &b
}
Пример #2
0
func addLine(p0, p1 image.Point) *line {
	obj := canvas.NewLine(image.Black, p0, p1, 3)
	window.AddItem(obj)
	ln := line{obj, p0, p1}
	lines = &lineList{ln, lines}
	lineVersion++
	return &lines.line
}