devotee
Simplistic visualization project.
Using devotee
Creating an app
Devotee app is represented by the Root implementation and a Backend system.
Root implementation
Root implementor must choose desired input system, pixel data converter, and render surface.
Also, it has to implement update, render and converter methods.
Minimalist Root implementation may look like this:
;
This Root implementation:
- Uses
NoInputas input system; - Relies on the
BlackWhiteConverter(implementation will be discussed later) to convert data of theRenderSurface; - Uses
Canvaswithboolpixels as aRenderSurface; - Does nothing during
update; - Draws nothing during
render; - Returns
BlackWhiteConverterinstance for data conversion;
The sample BlackWhiteConverter is implemented as:
;
It ignores x and y coordinates of the pixel and returns either pure white or pure black depending on the data value.
Backend usage
So, with the Root being implemented it is time to launch it using some backend.
For this example we will rely on the Softbuffer-based backend implementation.
Updating app state
Consider Extended implementation of Root.
Let it use Keyboard as input.
It shuts down on the Escape button being pressed.
Also, it counts passed simulation time in counter.
So, first part of its implementation looks like this:
During render it cleans render surface, calculates the surface center and draws two filled circles using painter.
Painter instance accepts functions as arguments instead of pure colors.
The function decides what to do with the pixel passed given its coordinates.
paint is a predefined function to override any original value.
Note that there are two implementations of painter: for i32 coordinates and (subpixel one) for f32 coordinates.
//. ..
// ...
Examples
There are some examples in the examples folder.
License
devotee is licensed under the MIT license.