This is an implementation of kaleidoscope pattern generator written in C#.
- GUI:
- Windows Presentation Foundation
- Gtk
- Pattern types:
- 3 mirror pattern
- 4 mirror pattern
- User parameters:
- Base geometry texture (from file)
- Base geometry width
- Rendering:
- 2D trough the Windows Presentation Foundation (WPF) Imaging Component
- 3D trough Windows Presentation Foundation (WPF) 3-D functionality
- 2D trough Cairo
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.
Now we can duplicate this image and reflect it along one of the sides of the base triangle.
We can repeat that with the newly created triangle.
Now we can clone the whole triangle row and flip it vertically.
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.INode
KaleidoscopeGenerator.Data.IGeometry
KaleidoscopeGenerator.Data.ITransformation
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 = factory.Get(KaleidoscopeTypes.Triangle);
NodeImpl rootNode = kaleidoscope.Generate(
geometryWidth,
imageUri,
viewportWidth,
viewportHeight
);
Original | Result |
---|---|
Original | Result |
---|---|
- 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