From 4d25c0ead14a811d6117cc8eae5aeaf0a51bb85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Mon, 20 Mar 2023 00:29:33 +0100 Subject: [PATCH] pot align --- main.go | 22 +++++++++++++++++++++- options.go | 1 - 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index c619320..f1df80b 100644 --- a/main.go +++ b/main.go @@ -39,8 +39,28 @@ func main() { sc.Clear() - // -a --align=INT Align tree: center=0 left=1 right=2 + // default center position px, py := opts.pot.ulPos(sc) + + // align by moving 1/4 screen size + switch opts.align { + case left: + sw, _ := sc.Size() + px = px - (sw / 4) + case right: + sw, _ := sc.Size() + px = px + (sw / 4) + } + + // user defined position overrides + if opts.baseX != 0 { + px = opts.baseX + } + if opts.baseY != 0 { + py = opts.baseY + } + + // draw pot opts.pot.draw(sc, px, py) // draw from pot upwards diff --git a/options.go b/options.go index 4c0727f..76f909b 100644 --- a/options.go +++ b/options.go @@ -85,7 +85,6 @@ func options() opts { log.Panicln("unknown pot type", strconv.Itoa(*pot)) } - // TODO: use align to set base-x and base-y values relative to window-size o.align = align(*alignRaw) o.leaves = strings.Split(*leavesRaw, ",")