instructions in file.
1 MA1008 Introduction to Computational Thinking Mini Project: Algorithmic art – designing repeated patterns Semester 1, AY 2020/2021, Week 10 – Week 13 1. Introduction The objective of the mini project is for you to produce a program of a moderate size that will require you to utilised what you have learned in this course, and more, to do something interesting. This project requires you to write a program that can be used to design and display repeated geometric patterns. These patterns can be made of lines and curves, and simple shapes, such as circles, polygons and stars, filled or unfilled with colours, which can be repeated and placed together to form pretty artistic patterns. Such patterns are used in many real-life practical designs, such as wall tiles, Islamic art, window and gate grills (Figure 1) etc. (a) Geometric patterns (b) Wall tiles (c) Islamic art (d) Window and gate grills Figure 1: Interesting repeated patterns captured from the Internet 2. What you need to do You need to write a Python program that can produce interesting repeated geometric patterns and display them graphically. There is no constraint as to the shapes and colours of the patterns; the choice is yours. You will need to provide facilities to create the underlying simple shapes (called primitives) and then methods to generate repetition of these shapes to form a complete picture. Your program needs to provide control mechanisms to generate the patterns. There should be flexibility in the control so that your user can vary the patterns, as freely as possible. Your program should have these capabilities: 1. Defining of the primitives 2. Duplicating of the primitives 3. Creating a pattern based on duplications of the primitives 4. A system for controlling the creation of the primitives and the patterns 5. Storing and retrieving the control parameters for generating a pattern 2 Further details on the capabilities are provided below. Defining primitives Shapes are defined by their geometry, which require coordinates of points. These points are joined to form the shapes. Primitives are shapes that you define in your system that the user can call and use directly without recreating the geometry. Hence you need to provide a library of primitives, such as circles, polygons (with different number of sides), stars (with different number of points), and any other shapes that you care to create. These primitives would have control parameters, such as positions of key points, radius, number of sides, lengths, angles, etc. The number and types of parameters and the way they may be controlled depend on the individual shapes. You may also offer user-defined primitives which the user can create beyond the primitives you provide. Your program needs to allow the user to select the specific primitive required and specify the controlling parameters so that it appears in the right place in the right size and orientation. You can provide appearance parameters to control the appearance of a primitive, such as the thickness and colour of the edges, and whether the interior is to be filled with a user-defined colour. By the way, a primitive does not need be a closed shape. It could, for example, be two lines that form a cross. It could also be a curve. (You will need to learn how to define curves.) Duplicating primitives You need to provide facilities to duplicate a selected primitive in a controlled manner, such as making a fixed number of copies along a straight line in a particular direction, or along a circular arc or in some other patterns. There needs to be control parameters too for the distribution of the duplication, such as at a fixed distance apart, or a certain number of copies within a given distance. You may also allow the geometry of the primitive to vary in the duplication, such as each new copy growing/shrinking by a given proportion or rotated by a certain angle. The variety of controls and the flexibility offered are up to you, but you need to provide facilities within your program to allow the user to control them. Creating a picture of patterns based on duplications You can compose a picture of patterns by duplicating the primitives. A pattern can be a composite of different primitives duplicated in different ways. You need to provide the flexibility for the user to make their choice and control the pattern. The sophistication and the quality of the outputs that can be produced depend on what you allow the user to do. A system for controlling the creation You will need to provide a mechanism to allow the user to use your program systematically. The control must include selection of the primitives, their appearance parameters, and the duplication parameters. In the case of a pattern consisting of multiple primitives, your system needs to allow for multiple selections. Storing and retrieving of the control parameters In generating a pattern, your user needs to provide certain data, such as the geometry and appearance of the primitives, the number of repetitions, the direction of the repetition, and so forth. These data need to be stored in a file to enable retrieval and recreation of the pattern later. Therefore, you need to provide file handling facilities for the storing and retrieval of your design data. The format of the data storage is up to you to design. 3 3. Resources The main external resource that you will need for this project is the graphics library provided with Python, called Turtle. Turtle capabilities and functions are described fully in Section 24.1 of the Python documentation, which you can access via the IDLE interactive shell by clicking Help > Python Docs and then search for “Turtle”. Turtle provides the functions required for drawing, such as plotting points, lines and shapes, and controlling their attributes such as location, colour, line thickness, and more. You should study the different Turtle functions that are required for your graphics. There are many Turtle functions, you only need to learn the ones you require. It is therefore necessary that you work out what you need beforehand. 4. What you need to submit 1. You need to submit a working Python program that allows the user to create graphical designs of repeated patterns, with mechanisms for controlling the patterns and the primitives therein. 2. You also need to submit a report in a Word file, providing the following: i. A user manual for your program which should: a. State the primitives your program provides and, for each primitive, state the parameters available to control the geometry and appearance of the primitives. b. State the facilities you provide to create repeated patterns of the primitives c. Provide a guide on how to run your program, including how to store and retrieve the data from file. ii. A set of at least four example outputs that your program produces. These examples should be as different as possible. iii. Any key strengths and limitations you wish to highlight about your program. 3. You need to submit the data files used for generating the examples in your report, so that your grader can reproduce them. 5. Grading Rubrics Here are what the graders will be looking for when grading: 1. The quality of the patterns produced, exemplified by the outputs provided in your report, as well as the outputs the graders can produce using your program. The factors they will be looking for are the types and flexibility of control you provide for generating different outputs, including the use of colour for lines and shapes. Two key words: flexibility and richness. 2. The ease of using your program to control the parameters in generating the patterns. 3. The quality of your program, which includes: • How easy it is to read and understand your program. This means your program should be adequately commented with good choice of variable and function names. • Modularisation of the program including appropriate use of functions. • The design of the functions which include the appropriateness of parameters in the functions. 6. Epilogue This project has unlimited scope for generating outputs of different quality and sophistication. It is open-ended, in the sense that one can keep on creating different primitives and providing flexible control parameters for them and for the patterns, and ultimately for composing impressive graphical outputs. We are not specifying the minimum or maximum variations or sophistication. Clearly, if a program is very limited in capability, it will not attract a good grade. Still, start by doing simple things correctly first. What you produce depends on the time you spend on the project and your ability in creating good algorithms and writing good code. This is an individual project. You may discuss and consult with your classmates, but everyone must write their own program. Any program deemed to have been copies of each other will be penalised heavily, regardless of who is doing the copying. 4 7. Examples The following figures give some examples of simple repeated patterns making interesting designs. Interesting window grill designs constructed from one primitive on the top left. A pattern of squares in circles A pattern of squares in circles with alternate rotated squares 5 Circles with filled colours and alternate rotated squares A pattern of linearly distributed circles with varying sizes and colours A circular distribution of 5-point stars with diminishing sizes towards the centre