summaryrefslogtreecommitdiffstats
path: root/pkg/draw/canvas.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/draw/canvas.go')
-rw-r--r--pkg/draw/canvas.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/pkg/draw/canvas.go b/pkg/draw/canvas.go
new file mode 100644
index 0000000..0235c66
--- /dev/null
+++ b/pkg/draw/canvas.go
@@ -0,0 +1,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)
+}