What's new in v0.6.0
Version 0.6.0 improves on the random rule generation and adds support for direction based characters, as well as some fixes and general maintenance.
🔀 Direction Based Characters
You can now map characters from the head_char array to specific turns and directions using the new direction_based_chars = true config option. Check out the new pipedream and transistor examples to see what it can do.
Characters are picked based on the direction they are coming from in combination with the direction they are travelling. This is achieved by mapping indices of the array to specific directional rules:
(Some(Direction::Up), Direction::Up) => 0, // │
(Some(Direction::Up), Direction::Down) => 0,
(Some(Direction::Down), Direction::Down) => 0,
(Some(Direction::Down), Direction::Up) => 0,
(Some(Direction::Left), Direction::Left) => 1, // ──
(Some(Direction::Left), Direction::Right) => 1,
(Some(Direction::Right), Direction::Right) => 1,
(Some(Direction::Right), Direction::Left) => 1,
// Turns
(Some(Direction::Up), Direction::Right) => 2, //┌
(Some(Direction::Left), Direction::Down) => 2,
(Some(Direction::Up), Direction::Left) => 3, // ┐
(Some(Direction::Right), Direction::Down) => 3,
(Some(Direction::Down), Direction::Right) => 4, // └
(Some(Direction::Left), Direction::Up) => 4,
(Some(Direction::Down), Direction::Left) => 5, // ┘
(Some(Direction::Right), Direction::Up) => 5,
// Diagonals
(Some(Direction::UpRight), Direction::UpRight) => 6, // ⟋
(Some(Direction::UpRight), Direction::DownLeft) => 6,
(Some(Direction::DownLeft), Direction::DownLeft) => 6,
(Some(Direction::DownLeft), Direction::UpRight) => 6,
(Some(Direction::UpLeft), Direction::UpLeft) => 7, // ⟍
(Some(Direction::UpLeft), Direction::DownRight) => 7,
(Some(Direction::DownRight), Direction::DownRight) => 7,
(Some(Direction::DownRight), Direction::UpLeft) => 7,
// Diagonal turns
(Some(Direction::UpRight), Direction::DownRight) => 8, // ⟋⟍
(Some(Direction::UpLeft), Direction::DownLeft) => 8,
(Some(Direction::DownRight), Direction::UpRight) => 9, // ⟍⟋
(Some(Direction::DownLeft), Direction::UpLeft) => 9,Using this logic, our head_char array could look something like this:
head_char = ["│", "──", "╭─", "╮", "╰─", "╯", "⟋", "⟍", "⟋⟍", "⟍⟋"]Which would give us the pipes.sh-like look seen in the new pipedream example.
While this supports the vast majority of possible directions, it does not cover all cases. Supporting individual characters for any possible turn and direction combination, at least using the current method, has diminishing returns in terms of config complexity. Any direction this system does not cover therefore falls back to the index 0, the first character in the head_char array. A more granular system is definitely doable, but requires larger changes.
🎲 Improved Random Generation
The original implementation for randomly generated rules was a bit clunky, and often resulted in simulations that would immediately halt, or were just generally uninteresting. A new system has been introduced that internally decides if a rule is good or not based on several parameters; it values Left/Right balance, variety in directions, and prioritises rules that are not too long and not too short.
This gives more consistent random generation, while reducing the amount of short-lived simulations. Here is a video demonstrating the new rule generation in combination with direction_based_chars = true and the head_char array set like this:
head_char = ["▌", "──", "▚", "▞", "│", "▜", "▂▂","▔▔"]trmt_v0_6_0_demo.mp4
👾 New Examples
Two examples have been added to showcase the new direction_based_chars option; pipedream and transistor:
Pipedream
Transistor
🏗️ Internal Improvements
- Split config module for better maintainability
- Added missing config validation for
fade_trail_color
🔧 Fixes
- Initial direction of heads are no longer hardcoded to
UP, but instead correctly uses the direction of the first rule in the rule string - Removed height constraints on help popup for better readability
📚 Other Changes
- README updates reflecting new workflows
- Updated dependencies
- Update rand from 0.8 to 0.9.1
- Update crossterm to latest 0.29

