summaryrefslogtreecommitdiff
path: root/share/hackvr/examples
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2020-02-23 22:39:08 -0600
committerepoch <epoch@hacking.allowed.org>2020-02-23 22:39:08 -0600
commitb6f6cb19848d885efbe69dc11a25c9e9a3b2d062 (patch)
tree6291b5f4ee9a7dfd1f0d93f67fa5cb0a55837fae /share/hackvr/examples
parent3e86b5b618aec197df2ffe58369bcea6f8428bcb (diff)
downloadhackvr-b6f6cb19848d885efbe69dc11a25c9e9a3b2d062.tar.gz
hackvr-b6f6cb19848d885efbe69dc11a25c9e9a3b2d062.zip
made fib.sh not just pseudo-code
Diffstat (limited to 'share/hackvr/examples')
-rwxr-xr-x[-rw-r--r--]share/hackvr/examples/fib.sh34
1 files changed, 23 insertions, 11 deletions
diff --git a/share/hackvr/examples/fib.sh b/share/hackvr/examples/fib.sh
index 9a9cf5c..c1d87ab 100644..100755
--- a/share/hackvr/examples/fib.sh
+++ b/share/hackvr/examples/fib.sh
@@ -1,12 +1,24 @@
-#!/bin/sh
-s=1 1 2 3 5 8 13
-x=0 0 1 0 -5 -5
-y=0 1 0 -3 -3 0
-
-for i in 1 1 2 3 5 8 13 21 34 55 89;do
- x=0
- y=0
- w=i
- h=i
- addshape 2 4 x y 0 x+w y 0 x+w y+h 0 x y+h 0
+#!/usr/bin/env bash
+z=0
+a=1
+b=1
+
+for i in $(seq 1 10);do
+ if [ $[$i % 2] = 0 ];then
+ x=$[$z]
+ y=0
+ else
+ x=0
+ y=$[$z]
+ fi
+
+ w=$a
+ h=$a
+
+ echo fib_$a addshape 2 4 $x $y 0 $[$x+$w] $y 0 $[$x+$w] $[$y+$h] 0 $x $[$y+$h] 0
+ z=$a
+ s=$[$a+$b]
+ a=$b
+ b=$s
+
done