dot

packages and services management
Log | Files | Refs | README

commit bb796dd689a88eea8c7fc431097ef89253f59ee2
parent 20be1e86494ec937a7a950c5d1b238b255ebd5f1
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Wed, 26 Jul 2017 01:24:27 +0200

bin/plot: more economical drawing

Diffstat:
Mbin/plot | 15+++++----------
1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/bin/plot b/bin/plot @@ -16,7 +16,6 @@ BEGIN { } { - printf "." maxx = split($0, dots) maxy = 0 @@ -26,16 +25,12 @@ BEGIN { if (maxy < dots[x]) maxy = dots[x] } - # fill the grid - for (x = 1; x <= maxx; x++) - for (y = maxy + maxy % 2; y >= 1; y--) - grid[y "-" x] = dots[x] < y ? 0 : 1 - # draw the grid - for (y = maxy + maxy % 2 + 1; y >= 1; y -= 2) { - for (x = 1; x <= maxx; x++) - printf grid[y "-" x] && grid[y + 1 "-" x] ? ":" : \ - grid[y "-" x] && !grid[y + 1 "-" x] ? "." : " " + for (y = maxy; y >= 1; y -= 2) { + for (x = 1; x <= maxx; x++) { + printf (dots[x] >= y + 1 ? ":" : \ + dots[x] >= y ? "." : " ") + } print "" } }