Task 093: Generate an Interesting Animation by using Lines / Polylines

Devise and implement an animation that is drawn using via lines and/or polylines. The animations must be computed frame by frame ("off-line rendering"), which are later combined into an actual movie, e.g. via the ffmpeg application.

Screenshot

Overview

The template application 093animation from the repository grcis serves as the basis of this project. It is a simple application that repeatedly runs your method Animation.DrawFrame() and writes the results to individual PNG files. The calculation is done in a separate thread so that it can, if necessary, be interrupted via the Stop button.

Possible Themes

For instance, move or change a shape in the plane. A 3D effect you would have to handle yourself, e.g. by drawing back-to-front (i.e. via the painter's algorithm). There are no limits on your imagination, you only have to draw the animations frames, finish your program and only use the class Canvas. This means that apart from the movie generation/encoding tools, no other tools may be used.

Canvas

The images must be generated via the Canvas class, which has the following API (identical to those in task 082):

  • 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.

Technical details

The method Animation.DrawFrame() is handed data on the current time (see the reference implementation) and a reference to the Drawing Canvas object. The method also has access to data that defines the image size.

You can not assume anything about the order in which individual frames of the animation are rendered. Individual threads can draw images in any order. At the beginning of calculating the animation (or before each picture) your method Animation.InitAnimation() is executed: there, you can put any initialisation of global shared data, and suchlike. If you need to perform a comprehensive calculation (physical / mechanical simulation, etc.), you must also run InitAnimation().

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.

Production of the video file

See e.g. this manual. ffmpeg binaries for Windows can be downloaded e.g. here. The generated video can be uploaded to YouTube: send us the link to the video once you are done with that! And do not forget to attach the source file Animation.cs.

Deadline

Hand in the assignment until: 9. 1. 2017

Points

Basic: 5 to 20 points, depending on difficulty and attractivity of the solution.
Bonus: for exceptional solutions

Projekt

Visual Studio project: 093animation

Source file

Modify and hand in the source file: Animation.cs
As a comment in the first line, please include your name!
Do not forget to send a link to your video!

Contest

Please vote in the contest before xx. 1. 2017 (date to be announced).


Copyright (C) 2015-2016 J. Pelikán & A. Wilkie, last change: 2015-10-26 15:29:49 +0100 (Mo, 26 Okt 2015)