summaryrefslogtreecommitdiffstats
path: root/pkg/draw/canvas.go
blob: 0235c66301419be81e80717383ffdeea0563fb78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package draw

type Pixels interface {
	GetBuffer() *Buffer
	Clear()
	Set(y, x int)
	Size() Box
}

type Canvas struct{ Pixels }

func (c *Canvas) RuneSize() Box {
	pixelBox := c.Size()
	runeBox := c.GetBuffer().Box
	return Box{
		Width:  pixelBox.Width / runeBox.Width,
		Height: pixelBox.Height / runeBox.Height,
	}
}

func (c *Canvas) DrawLine(y0, x0, y1, x1 int) {
	line(y0, x0, y1, x1, c.Set)
}