summaryrefslogtreecommitdiffstats
path: root/pkg/draw/canvas.go
diff options
context:
space:
mode:
authorSergey Grebenshchikov <sgreben@gmail.com>2018-03-28 17:27:59 +0200
committerSergey Grebenshchikov <sgreben@gmail.com>2018-03-28 17:46:08 +0200
commitc76ad10b1dc63beeee3cf4fa8f4f4f4b02222289 (patch)
treee5735d201e3ab6267a75dec79ed5d53b0bcdf635 /pkg/draw/canvas.go
parent7e3d9839123783e5c367522953e494789ce3618d (diff)
Add braille & quarter-block canvas. Add scatter plot type. Re-write linechart + barchart.
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)
+}