A Kobayashi Valentine’s Day Card
The Math Behind the Art in our Kobayashi Valentine
At first glance, this tool might look like a random pattern generator of little squares, but there is no randomness here. Every square, circle, and color choice is defined by a specific mathematical rhythm.
This tool is inspired by the work of Shoshichi Kobayashi, a geometer (first time I have used the word) known for bridging complex figure analysis and geometry. He is most famous for the Kobayashi Metric, a way of measuring the distance inside complex, multi-dimensional shapes where standard measuring doesn’t work. His metric helps mathematicians map out “hyperbolic” spaces that curve in impossible ways. In a simpler this art tool uses a sequence to map out a grid that splits and evolves organically.
Here is how the Kobayashi Art Tool turns little squares into pleasing art. Choose the heart cutout overlay option, and it makes a charming Valentine’s Day card. If you are looking for other Valentine’s Day ideas, try my prose and poetry blackout poem tool.
Kobayashi Valentine
Select a mood, cut the shape.
Coloring Page
The Sequence
At the core of this tool is a number sequence: [1, 2, 3, 5, 8, 13, 21, 34].
You might recognize this as the start of the Fibonacci Sequence, which appears everywhere in nature, from the arrangement of sunflower seeds to the spiral of a nautilus shell. In this tool, I use these numbers not to measure things, but to control probability and style.
Instead of picking colors randomly, the code looks at the “depth” of the current square (how small it is) and checks the sequence. If the number is even, it might draw a circle; if it’s odd, a square. This ensures the art feels “organic” rather than just “noisy.”
The Structure: Recursive Tiling
The grid logic is based on a computer science concept called a Quadtree.
Imagine a large square piece of paper. You flip a coin.
- Heads: You leave the paper alone.
- Tails: You cut the paper into four smaller, equal squares.
Then, you pick up each of those four small squares and flip the coin again for each one. You keep doing this until the squares are too small to cut. This process is called Recursion.
In my tool, the probability of “cutting” gets lower the smaller the square gets, which creates that pleasing balance of large “negative space” areas and dense, detailed clusters of tiny shapes.
The Colors: Modulo Arithmetic
How does the tool know which colors to use? It uses a mathematical operator called Modulo
Modulo uses the remainder from division to select a color. This creates a cycling harmony, ensuring that no matter how complex the grid gets, the colors never clash; they just loop through the color selection theme.