#!/bin/sh
set -eu

THEME=curated
SECONDS=45
FOREVER=0
LOADERS=0

while [ "$#" -gt 0 ]; do
  case "$1" in
    --industrial|industrial|--manly|manly)
      THEME=industrial
      ;;
    --rainbow|rainbow|--neon|neon)
      THEME=rainbow
      ;;
    --curated|curated|--bold|bold)
      THEME=curated
      ;;
    --theme)
      shift
      THEME="${1:-curated}"
      ;;
    --forever)
      FOREVER=1
      ;;
    -loaders|--loaders|loaders)
      LOADERS=1
      ;;
    --seconds)
      shift
      SECONDS="${1:-45}"
      ;;
    *)
      SECONDS="$1"
      ;;
  esac
  shift
done

TEXT=$(cat <<'__KNOTT_TEXT__'
Knott Dynamics is dedicated to advancing
the field of humanoid robotics through the
principles of nature: tendons, leverage,
and movement.

We build machines that move
with purpose, adapt with intelligence,
and interact with the world
as extensions of life.

This compendium documents our
understanding of the mechanisms
that make it possible.

Knott Dynamics

A humanoid machine is not assembled
from parts alone.

It is composed of relationships:
force and resistance,
weight and balance,
signal and response.

Every joint must serve motion.
Every actuator must serve intention.
Every mechanism must disappear
into the grace of the whole.

Nature rarely pushes where it can pull.

The tendon is a line of force,
a messenger between motor and limb,
a cord that allows strength to travel
through distance, angle, and constraint.

In the humanoid form,
tendons allow the machine
to become less rigid,
less mechanical,
and more alive in motion.

Leverage is the quiet multiplication
of strength.

A small force, correctly placed,
may move a great weight.
A short rotation, correctly guided,
may command an entire limb.

The study of leverage is the study
of where power wishes to enter
the body.
__KNOTT_TEXT__
)

if [ "$LOADERS" -eq 1 ]; then
  if [ "$FOREVER" -eq 1 ]; then
    ./run.sh loaders --forever --width 72 --height 5 --fps 6
  else
    ./run.sh loaders --seconds "$SECONDS" --width 72 --height 5 --fps 6
  fi
elif [ "$FOREVER" -eq 1 ]; then
  ./run.sh showcase --theme "$THEME" --text "$TEXT" --forever
else
  ./run.sh showcase --theme "$THEME" --text "$TEXT" --seconds "$SECONDS"
fi
