Skip to content

catbieber/creating-symmetry

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Symmetrical Pattern Generator

This program lets you transform an image in to an image with symmetrical pattern. Just supply a base image and a formula to get started.

Image with 7 horizontal stripes creating the rainbow with white on top and black on the bottom. Rainbow Stripe

Transformed rainbow stripe image into rosette with 3 rotational symmetry Transformed rainbow stripe image into frieze with p11g symmetry, with blue and yellow hourglasses in a green background Transformed rainbow stripe image into hexagonal lattice with p31m symmetry, with purple, indigo and blue nodes against a transparent background

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 check out this repository, open a terminal and navigate to this codebase.

Run go install and it will download the other required libraries:

  • yaml
  • ginkgo
  • gomega
  • check

You will need a source image. A rainbow stripe pattern is included in this repository and used throughout these docs.

Rainbow Stripe with white stripe on top and black stripe on the bottom

How to run

Open your command line and type: make run

This will look for the file data/formula.yml to find the required settings:

  • The name of the source image
  • The name and size of the output image
  • The formula that transforms the source into the output
  • Numerical ranges used with the formula

All options (except the formula) are described here.

Example

If you learn better by example, try renaming data/formula.yml.example to data/formula.yml. When you run make run, it will generate the orange and red pattern you see below.

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.

Transformed rainbow stripe image into rosette with 3 rotational symmetry, creating three yellow to purple petals on a orange and red striped background

3 way rotational symmetry

Transformed rainbow stripe image into rosette with 4 rotational symmetry, creating purple and green petals on a blue background

4 way rotational symmetry

Transformed rainbow stripe image into rosette with 5 rotational symmetry, creating a 10 point mostly green hubcap

5 way rotational symmetry

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.

Transformed rainbow stripe image into frieze with p11g symmetry, with blue and yellow hourglasses in a green background

Reflective symmetry across the x-axis

Transformed rainbow stripe image into frieze with p2111 symmetry, like an orange branch with black notches separated by blue and white droplets

2 way Rotational symmetry

Transformed rainbow stripe image into frieze with p2mg symmetry, with multicolored spikes emerging from a green background

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.

Transformed rainbow stripe image into rectangular lattice with pmg symmetry, with green and orange round rectangules on a yellow background

Rectangular lattice. The lattice connects the 4 centers of the green and orange ovals. Then the lattice is repeated to create the image.

Transformed rainbow stripe image into hexagonal lattice with p31m symmetry, with purple, indigo and blue nodes against a transparent background

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.

Transformed rainbow stripe image into rhombic lattice with cmm symmetry. Red and orange blobs sit interlocked against a transparent background

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.

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!

About

Create symmetrical wallpapers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Go 99.8%
  • Makefile 0.2%