Skip to content

imagineblueeyes/KaleidoscopeGenerator

 
 

Repository files navigation

Kaleidoscope Pattern Generator

This is an implementation of kaleidoscope pattern generator written in C#.

Kaleidoscope

Features:

  • GUI:
    • Windows Presentation Foundation
    • Gtk
  • Pattern types:
    • 3 mirror pattern
    • 4 mirror pattern
  • User parameters:
    • Base geometry texture (from file)
    • Base geometry width
  • Rendering:

Algorithm

Kaleidoscope patterns are a combination of reflected and translated copies of a base image. We start of with a triangle positioned in the center of the screen.

Step 1

Now we can duplicate this image and reflect it along one of the sides of the base triangle.

Step 3

We can repeat that with the newly created triangle.

Step 3

Now we can clone the whole triangle row and flip it vertically.

Step 3

Implementation

The goal of the design was to separate data generation from data rendering. Data generation has been implemented in the KaleidoscopeGenerator.Data module. The GUI and the rendering strategies reside in the KaleidoscopeGenerator.GUI namespace.

The generation algorithm creates a tree data structure of nodes. Each node consists of a geometry, a list of child nodes and a transformation that applies to the geometry and all its child nodes.

To use the generation library a client has to implement 3 interfaces:

  • KaleidoscopeGenerator.Data.ÌNode
  • KaleidoscopeGenerator.Data.ÌGeometry
  • KaleidoscopeGenerator.Data.ÌTransformation

The main interface to the library is a generic factory:

var factory = new KaleidoscopeFactory<NodeImpl, GeometryImpl, TransformationImpl>();

To generate a pattern get an instance of a concrete pattern generator and call Generate():

var kaleidoscope = new factory.Get(KaleidoscopeTypes.Triangle);

NodeImpl rootNode = kaleidoscope.Generate(
  geometryWidth,
  imageUri,
  viewportWidth,
  viewportHeight
);

Results

3 Mirrors

Original Result
demo demo
demo demo
demo demo

4 Mirrors

Original Result
demo demo
demo demo
demo demo

TODO

  • Improve robustness of the loading and saving functionality
    • Refactor exception handling (Wrap framework exception)
    • Better user error notifications
  • Improve performance by resizing loaded images if they are too big
  • Add fading per level support to the generation algorithms
  • Move Viewpord2D and Viewport3DExt code into a ViewModel (confom to MVVM pattern)
  • Add animated texture support
  • Add more tests

About

Implementation of kaleidoscope pattern generator written in C#.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%