From f0ca9f2ca922c9bd5587a2371b4ad1b81c404cb0 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 8 Jan 2017 19:20:51 +0100 Subject: Cleanup plotter --- tek.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'tek.go') diff --git a/tek.go b/tek.go index 34c3bb6..84adc65 100644 --- a/tek.go +++ b/tek.go @@ -5,15 +5,11 @@ import ( "os" ) -const ( - height = 3072 - width = 4096 -) - type Out struct { io.Writer hix, hiy, lox, loy, eb byte xterm bool + height, width int } func (o *Out) escString(s string) { @@ -29,6 +25,8 @@ func NewOut(w io.Writer) *Out { return &Out{ Writer: w, xterm: os.Getenv("TERM") == "xterm", + height: 3072, + width: 4096, } } @@ -64,9 +62,13 @@ func limit(val, max int) int { return val } +func (o *Out) Dim() (w, h int) { + return o.width, o.height +} + func (o *Out) Plot(x, y int) { - x = limit(x, width) - y = limit(y, height) + x = limit(x, o.width) + y = limit(y, o.height) hiy := byte(y>>7) & 0x1f loy := byte(y>>2) & 0x1f -- cgit v1.2.3