Task 099: Generate an interesting image by only using horizontal and vertical lines

Your task here is to generate a technically and visually interesting image that is created only from horizontal and vertical lines.

Screenshot

Possible Themes

  • Fractals (L-systems, and such)
  • 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 099lines 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.
  • MoveTo ( float x, float y, int dir =DIRECTION_KEEP ) - moves the current position to [x, y], and optinally changes drawing direction (see the DIRECTION_ * constants in the source) as well.
  • MoveRel ( float dx, float dy, int dir =DIRECTION_KEEP ) - moves the current position by the vector [dx, dy], and optinally changes drawing direction (see above) as well.
  • HLineTo ( float x ) - draws a horizontal line to the point [x,*] with the currently set pen (color and thickness).
  • HLineRel ( float dx ) - draws a horizontal line of length dx from the current position, with the currently set pen (color and thickness).
  • HLineTo ( float y ) - draws a vertical line to the point [x,*] with the currently set pen (color and thickness).
  • HLineRel ( float dy ) - draws a vertical line of length dy from the current position, with the currently set pen (color and thickness).
  • Draw ( float d ) - draws a line of length d, using the selected pen.
  • Skip ( float d ) - move a distance d without leaving a trace.
  • Right () - turn 90°rees right.
  • Left () - turn 90°rees left.
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 modified 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: 26. 11. 2017

Points

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

Project

Visual Studio project: 099lines.

Source file

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


Copyright (C) 2016 J. Pelikán & A. Wilkie, last change: 2019-05-09 17:52:59 +0200 (Thu, 09 May 2019)