🐧 Spiral
⭐⭐ Like this project? Support my work by giving it a star on GitHub ⭐⭐
1) Overview
A flexible, dictionary-driven Java utility designed to map and print strings into multi-dimensional matrix layouts. Unlike static matrix printers, this project uses customizable tracking dictionaries to control the precise layout sequence, supporting frame, clockwise, and snake-like patterns.
The Spiral Matrix Printer takes an input string and show it into a row-and-column matrix grid. The exact path, direction, and sequence of the string injection are dynamically controlled by a dictionary. This structural abstraction allows you to print matrix outputs in completely different structural geometries simply by altering the input dictionary.
2) Use cases
- Data Visualization: Mapping serial data streams into structured multi-dimensional paths.
- Algorithmic Modeling: Understanding grid traversal strategies and index mapping patterns.
- Game Development: Modeling custom snake, spiral, or coordinate boundary movements.
3) Supported patterns
The flow of characters into the grid boundaries is fully dictated by your chosen tracking configuration:
Frame spiral
Fills out the structural perimeter framework first before stepping inbound.
- Dictionary sequence:
a b c d e f t g s h r i q j p o n m l k - Output:
a b c d e f t g s h r i q j p o n m l k
Clockwise spiral
The classic matrix spiral pattern. Moves from top-left, tracks inward via tightly winding concentric rings until it reaches the dead center.
- Dictionary sequence:
a b c d e f t u v w x g s 6 7 8 y h r 5 0 9 z i q 4 3 2 1 j p o n m l k - Output:
a b c d e f t u v w x g s 6 7 8 y h r 5 0 9 z i q 4 3 2 1 j p o n m l k
Snake spiral
Tracks across rows using an alternating bidirectional path, turning back on itself at the boundary edge of each level.
- Dictionary sequence:
a b c d e f l k j i h g m n o p q r x w v u t s y z 1 2 3 4 0 9 8 7 6 5 - Output:
a b c d e f l k j i h g m n o p q r x w v u t s y z 1 2 3 4 0 9 8 7 6 5
4) Architecture & Project structure
The project relies on clean separation of layers, decoupling the underlying mapping logic from the stream output rendering layer:
src/
└── com/
└── remal/
└── spiral/
└── Test.java # Entry point with runtime parameters
├── Spiral.java # Core coordinates processor & grid builder
├── dictionary/
├── Dictionary.java # Core functions for dictionaries
├── FrameDictionary.java # A dictionary implementation
5) Getting started
5.1) Prerequisites
- Java Development Kit (JDK) 8 or higher.
5.2) Build & Execution
- Clone the repository into your local directory:
git clone https://github.com/zappee/spiral.git cd spiral - Compile the source code files:
javac src/com/remal/spiral/*.java -d bin - Run the application:
java -cp bin com.remal.spiral.Main
6) Source core
https://github.com/zappee/spiral
7) Contributing
Contributions, feature requests, and optimization are always welcome!