Task 123: Procedural generation of an image

Your task is to procedurally generate a 2D raster image. Your method, which returns one color, will be executed (independently) for every pixel of the image.



The application 117raster from the repository grcis (GIT) serves as the basis of this project. For detailed description refer to this page.

Your solution will use ModuleFormula module (documented in the 117raster application). Your solution should be implemented as a CS-script, which will be executed on every pixel of the image (formula.pixelCreate function). If loading of input parameters or some additional initialization is required, use function formula.contextCreate.

Alternative (for easier implementation and debugging of the code in the Visual Studio): instead of CS-script, you can write your implementation directly in full-fledged C# following the example of ModuleFormulaInternal module. Implementation requirements are the same, but the solution is not a CS-script anymore, and as such it is no longer be possible to modify the code and re-run it without recompilation of the whole project. On the other hand you will have available all features of Visual studio (e.g., code completion, debugger, ...).

Examples of scripts generating raster images are: Contrast.cs and Swap.cs (both can be found in the 117raster project folder). Contrast.cs generates colorful visualization of sinc(R2) function, and Swap.cs contains a variation of the same formula with discrete results and without use of goniometric functions.

You can observe how to read and parse input text parameters in the Swap.cs script. If you need to pass some values (parameters) to the formula.pixelCreate function, then save this value to the map Dictionary<string, object> (return value of formula.contextCreate). Later on, it will be accessible in the formula.pixelCreate via ic.context. For example see parameter "freq" (defining frequency of concentric circles) in Swap.cs.

Alternative: Example of alternative implementation via module (as a part of the project) is in modules/Formula/ModuleFormulaInternal.cs, specifically ModuleFormulaInternal class. Do not forget to adjust author name (and name of the module itself) in your implementation.


Regular shapes and ornaments, color transitions, fractals, ... Anything interesting and not completely trivial. Additional points can also be awarded for reasonable parametrization (not just e.g., specification of colors A and B).

Implement your solution in a script file similar to Contrast.cs or Swap.cs. It is necessary to define function formula.pixelCreate and potentially formula.contextCreate for argument parsing.

Alternative: your can also define your pixel function inside of a new class (see modules/Formula/ModuleFormulaInternal.cs for reference). Definition of lambda functions can be found in the GetFormula() method.

What to hand in

Your source file (CS-script). Include instructions for use - especially if you will use modifiable parameters (include their explanations and acceptable ranges of values). Instructions can be represented as a comment block or tooltip text.

Alternative: source file with implementation of your class derived from ModuleFormula.


Hand in the assignment until: 07. 11. 2021


3 to 10 bodů based on quality and originality of the results and available parametrization.


Visual Studio project: 117raster

Source file

Single source file (CS-script), usable as plugin in the ModuleFormula module. Alternatively, source file with implementation of your class derived from ModuleFormula.

Copyright (C) 2010-2021 J. Pelikán & V. Tázlar, last change: 2020-11-10 15:28:38 +0100 (Tue, 10 Nov 2020)