Creating Symmetry
This program lets you transform an image into an image with symmetrical pattern. Just supply a base image and a formula to get started.
I assume you're comfortable with Go, YAML and a command line. You'll install this in Go, write the formulas in YAML, and run make run
on a command line to generate pretty patterns.
Important pages
Installation
This program is written in Go, so download that first.
Once that is done, you can use go to get this project for you:
go get https://github.com/Chadius/creating-symmetry/
You will need a source image. A rainbow stripe pattern is included in this repository and used throughout these docs.
Manual Install using go install
If go get
doesn't work you can check out this repository directly. Then open a terminal and navigate to the folder this code lies in.
Run go install
and it will download the other required libraries:
- yaml
- ginkgo
- gomega
- check
How to run
Copy the example formula, and run the program.
cp data/formula.yml.example data/formula.yml
make run
When you run make run
, it will generate this orange and red rosette pattern:
You can open out/example_image.png
to see the results. (on a Mac, you can also type open out/example_image.png
to open it in Preview.)
What happened?
This program needs answers to these questions:
- What image do you want to transform?
- How do you want to transform the image?
- Where is the result stored?
make run
expands into this command:
go run main.go -in example/rainbow_stripe.png -f data/formula.yml -out out/example_image.png
And follows these steps:
- Transform this image:
example/rainbow_stripe.png
- Transform it with these instructions:
data/formula.yml
- Store the result in this image:
out/example_image.png
.
Command Line Options
-source, -in
Source filename, the image you want to transform.
-out
Output filename, where the result is stored.
-size
Output resolution, the size of the final image.
-f, -formula
The filename of the formula file. Defaults to ./data/formula.yml (default "formula")
Source Filename
The name of the image file. JPG and PNG are supported, as well as any format Go lang’s Image
library supports.
Examples:
-source example/rainbow_stripe.png
-in input/iceCreamSundae.jpg
Output Filename
The name of the output filename. All output files are in PNG format.
-out ouput/rainbow_stripe_frieze.png
Output Resolution
How big do you want the resulting image?
- Bigger images give more detail.
- Smaller images render faster.
Supply a pair of integers, separated with a single x.
Examples:
-size 200x200
-size 300x50
Types of patterns
Rosette
Rosette patterns surround the center of the image, expanding outward. They can be rotated around the center without visually changing the look.
Click here to learn more about rosette-based patterns and design your own.
Frieze
Frieze patterns expand horizontally forever but usually have a finite height.
Reflective symmetry across the x-axis
Glide symmetry: move the pattern horizontally a bit and then flip it over the x-axis
Click here to learn more about frieze-based patterns and how to build your own.
Lattice
Lattice patterns transform using a 4 sided shape called a lattice. They expand horizontally and vertically forever. Sometimes these are called wallpaper patterns.
Rectangular lattice. The lattice connects the 4 centers of the green and orange ovals. Then the lattice is repeated to create the image.
Hexagonal lattice Creates 3 way rotational symmetry. This lattice can be stacked 7 times to create a hexagonal pattern. Count the solid blue dots to see the corners of the lattices.
Rhombic lattice The lattice is based on a rhombus, where all sides are the same length but not at a square. All red blobs should look the same, but due to the low resolution rounding errors appear.
Click here to learn more about lattice-based patterns. (Still a Work In Progress!)
How to test
If you plan to mess around with the code itself, here are 2 more make commands that will come in handy:
make test
Runs the unit tests.make lint
Runs the linter and formats files.
Inspiration
Creating Symmetry by Frank Farris merges math and art to create beautiful patterns and is worth the read. Prepare for Group Theory and Complex Numbers!