Task 092: Generate an Interesting Image by using Lines / Polylines

The challenge here is to generate a technically and visually interesting image that is created only from lines and/or polylines.

Screenshot

Possible Themes

  • Fractals (alternative visualisations of the Mandelbrot set, fern leaves, ...)
  • other regular or irregular geometric shapes and patterns (spirals, recursive patterns, ...)
  • a variation on your favourite abstract painting (e.g. a generator of images in the style of P. Mondrian)
  • anything else you can think of, but the result should be interesting in more than one way: it should score both visually, technically and algorithmically. That is, it should not be just a complicated calculation which yields 2 lines, nor a pretty picture that is made up of 250 lines that are hard coded in the source.

Please do not submit a "bitmap converter", which only draws image points with short lines. If you need curved lines in your output, use a polyline to approximate such smooth curves!

Overview

The template application 092lines from the repository grcis serves as the basis of this project. This is a simple application in which you are supposed to implement the method Lines.Draw() which is responsible for calculating the output image. One can enter the desired resolution bitmap output and other parameters through a text form field.
The result is automatically displayed on the screen, and can be saved to disk in PNG format.

Technical details

The output must be generated via the Canvas class, which has the following APIs:
  • int Width - width of the generated image (after setting/modifying this, you have to call Clear()).
  • int Height - height of the generated image (after setting/modifying this, you have to call Clear()).
  • Clear ( Color bg ) - initialises the image, set the background color bg.
  • SetColor ( Color col ) - sets the drawing colour.
  • SetPenWidth ( float width ) - set the pen width for drawing lines.
  • SetAntiAlias ( bool aa ) - activate/deactivate anti-aliasing.
  • Line (float x1, float y1, float x2, float y2) - draw a line from point [x1, y1] to point [x2, y2] with the currently set pen (color and thickness).
  • Line (double x1, double y1, double x2, double y2) - draw a line from point [x1, y1] to point [x2, y2] with the currently set pen (color and thickness).
  • Polyline (PointF [] arr) - draws a polyline with the currently set pen (color and thickness).
  • Polyline (IEnumerable arr) - draws a polyline with the currently set pen (color and thickness).
Your method will have to cope with any reasonable image size selected by the user with an aspect ratio of 4: 3 (800 * 600px and above). The default size of the screen is 800 * 520px. The drawing methods correctly trim lines / polylines that exceed the canvas limits.

When calling Lines.Draw(), the following parameters are passed: a Canvas object c to which all your output has to be directed, and a free parameter text string param, which you can use to transmit additional useful information to the application. This is optional, though: the parameter param does not have to be used.

Initialisation of parameters: in order to have all relevant code nicely grouped in a single location, you can initialise your application parameters in the function InitParams(). It is called during application start-up.

In the last parameter field out string name please write your full name (as well as in the comments on the first line of the source file). This will make it easier to perform automatic evaluations of the results.

What to hand in

As solution of the problem, you have to send us the file Lines.cs (and only that). For this assignment, you can also add a successful final image that the program generates.

Deadline

Hand in the assignment until: 21. 11. 2021

Points

Basic: 6 points, plus a potential bonus of 6 points.

Project

Visual Studio project: 092lines.

Source file

Modify and hand in the source file: Lines.cs
As a comment in the first line, please include your name!


Copyright (C) 2010-2021 J. Pelikán & V. Tázlar, last change: 2021-10-31 23:48:20 +0100 (Sun, 31 Oct 2021)