Esempio n. 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
}
Esempio n. 2
0
func dragRect(cvs *canvas.Canvas, m draw.Mouse, mc <-chan draw.Mouse) draw.Rectangle {
	m0 := m
	r := draw.Rectangle{m0.Point, m0.Point}
	b := newBox(cvs, r)
	cvs.Flush()
	for m.Buttons != 0 {
		m = <-mc
		b.setRect(draw.Rectangle{m0.Point, m.Point}.Canon())
		cvs.Flush()
	}
	b.delete(cvs)
	cvs.Flush()
	return draw.Rectangle{m0.Point, m.Point}.Canon()
}
Esempio n. 3
0
func (b *box) delete(cvs *canvas.Canvas) {
	cvs.Delete(b.n)
	cvs.Delete(b.e)
	cvs.Delete(b.s)
	cvs.Delete(b.w)
}