Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you complete the whole thing in Processing, specially Q2 and Q3. In order to complete question 2 first part is needed. For which I

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Can you complete the whole thing in Processing, specially Q2 and Q3. In order to complete question 2 first part is needed. For which I posted the whole question. Please do not scam or give a different answer, I am already posting it for the 3rd time.

Read through the ENTIRE description for a question (and/or the assignment), take notes on the important points, and plan your code on paper BEFORE writing any code in Processing. In this assignment, you will program a plant, such as a flower or small tree. In Q1, you will draw a static image of your chosen plant. In Q2, you will make the plant change size and position based on your mouse position. In Q3, you will make the plant grow where you clicked your mouse towards the centre of the canvas. Q1: STARTING A GARDEN [7 MARKS] You should be able to do this question after Week 2 (Unit 4) in the course. Write a non-active Processing program (containing no setup() or draw () functions) which will draw a simple plant on the ground (e.g., a flower, a spruce, a stalk of wheat). The plant must be of your own design and should fill most of the canvas in Q1. Keep it simple and abstract. Do not copy the sample images. Your drawing does not have to be very realistic. Be creative. The rules for the drawing are: - It must contain from 6 to 12 shapes (lines, ellipses, rectangles, or other shapes). The sample here uses 12 shapes: 9 circles, 1 ellipse, 1 rectangle, and 1 line. - It must contain at least one line, at least one ellipse or circle, and at least one square, rectangle, triangle or quadrilateral (quad). - It must contain several different colours. Use any background colour as you like. - Use a 500500 canvas for this question. - It must use strokeWeight at least once to adjust the thickness of line(s). - Don't make it too complex. Stick to the limit of 12 shapes. That will make the remaining questions easier. - In this question, your object should fill most of the canvas, and be roughly centred. must also follow the rules below in your program: - At the top of your program, define three constants SIZE, X_CENTRE and Y_CENTRE which will control the size of your plant, and its position in the canvas. - The SI zE can be its length, width, or any other suitable dimension that you like (e.g., in the flower example above, SIZE is equal to the height/length of the flower's stem). - The coordinates X_CENTRE and Y_CENTRE should control the position of the object in the canvas, by defining some central point like the middle of the main shape. It doesn't have to be the exact centre (e.g., in the flower example above, X_CENTRE and Y_CENTRE are the coordinates of the middle of the top of the stem, at the bottom of the cream-coloured, central part of the flower). - Define suitable constants for all other dimensions and coordinates needed to draw the plant, such as heights, widths, diameters, stroke weights and the coordinates of corners and endpoints of lines. A/l of these constants must be calculated from some combination of SIZE, X_CENTRE and Y_CENTRE, or from constants that depend on these! They cannot be simple numbers! Only SIZE, X CENTRE and Y_CENTRE can have numerical values that are directly assigned to them without calculations! For example: - You do not need to use constants to define colours. - Use constants you have defined to draw the object. Every parameter in a drawing command should contain a constant. You should be able to change the size of the canvas, SI ZE, X_CENTRE or Y_CENTRE, and the object should still be drawn correctly at any size and in any location. - You can use some arithmetic and small constants like 1 or 2 in your drawing commands. For example, a formula like X_CENTRE+SIZE / 2 could be used for an X coordinate without storing it in a separate constant. This will reduce the number of constants needed. PAGE 2 OF 4 - Test your code thoroughly before starting Q2! Change SIZE and see if your object is redrawn larger or smaller. Change X_CENTRE and/or Y CENTRE and see if your object is drawn at the new location. If there are any distortions/squishing/stretching of shapes, or if shapes separate from each other, you need to reconsider your calculations. You are not ready to move on to Q2 until you can change these constants and have your object scale and move without distortion. Q2: GROWING PLANTS [9 MARKS] This question requires material from Week 3 (Units 5&6 ). Convert your program from Q1 into an Active Processing program, with the mouse controlling both the size and position of your plant: - Save a copy of your original Q1 program. You must hand in the original static version, as well as this modified active version. Rename this one so it ends with "A1Q2". - All of the constants defined in Q1 must now be changed into variables since they will now be changed by the mouse. The Find... command in the Edit menu contains a Replace All button which will be very useful to change names. - Create the usual setup () and draw () functions. - Write a function named setSizeXandY () that will use the mouse position to set the three variables that control the size and position of your plant: The centre (i.e., reference point) of your plant should always be at the mouse position. - The size of your plant should be controlled by mouseY. The object should have a size of MIN_SIZE when the mouse is at the top of the canvas, and MAX_SIZE when the mouse is at the bottom of the canvas and should change size smoothly in between. Define these two new constants at the top of your program (e.g., for the flower example, MIN_SIZE was set to 50, and MAX_SIZE was set to 400 , this defined the range of allowed sizes for the size of the stem). - Write a function named calcDimensions () that will calculate all of the variables that control the drawing of the plant (the ones that used to be constants but are now variables). The code should be almost the same as the constant declarations that you used in Q1 (the main difference being the names of the variables). - Write a function named drawXXXXX () (e.g., drawFlower ()) that will draw your plant. All of the drawing code should be moved into this function. You shouldn't have to change any of this code (except for the names of the variables). - Call these three functions appropriately from setup () and/or draw () (think about how often each function should run to decide where it should be called). - Your plant should follow the mouse around the canvas, and grow or shrink. It should work for any size canvas, and any reasonable values of MIN_SIZE and MAX_SIZE. PAGE 3 OF 4 Q3: GROWING THE GARDEN [6 MARKS] Convert your program from Q2 so that your plant grows all by itself, without being controlled by the mouse. Make the following changes and additions to your Q2 program: - Save a copy of your original Q2 program. You must hand in that version as well as this new version. Rename this one so that it ends with "A 1Q3 ". - Delete the MIN_SIZE and MAX_SIZE constants, which will no longer be used. - The plant should move along a line from the point where you click your mouse to a point in the centre of your canvas. Define variables xStart,yytart, which will store the values of the most recent mouse click. Define the constants X END, Y_END, to store the values of the centre of the canvas. - The plant's size should start at SIZE_START and end at SIZE_END. Define two different values so that the plant appears to grow towards the centre of the canvas. After the plant finishes growing and moving along its line, it should resemble the plant's size and position in Q1 (but doesn't have to be exactly the same). - Define a constant SPEED_FACTOR which will control the speed of the plant along the line. All three values ( x,y and size) should move 1/SPEED_FACTOR of the way from their current values toward the ending values in each frame. For example, if the plant is currently at x=450 and the centre of the canvas is 250 , a difference of 200 , then if SPEED_FACTOR is 20, the object should move 1/20 of the difference (10 pixels) in the x direction. If int variables and constants are used, this may result in some uneven motion near the end and/or the plant not ending in the exact center. That's OK. If you use float variables and constants instead, it will work more smoothly. floats are not required in this assignment. - Define the special void mouseClicked() function, which Processing will run automatically every time the mouse is clicked anywhere in the canvas. Do not call this function yourself! Whenever the mouse is clicked, the plant should reset to the mouse's position (and update xSt tart and ystart), and reset its size, then, in the frames that follow, it should start to grow towards the centre. If you are interested, more information about the mouseclicked () function can be found in Processing's documentation: - Modify your setSizeXandY() function so that the plant moves and changes size as described above. - You should not have to make any changes at all to the other functions (setup, draw, calcDimensions, or drawXXXXX). PROGRAMMING STANDARDS [5 MARKS] Assignments must follow the programming standards document published on the course website on UMLearn, as well as any standards described in the lectures (e.g., CONSTANT_NAMES vs variableNames). HAND IN Hand in three pde files, one each for Q1, Q2 and Q3. Make sure your files are correctly named, exactly as specified in the instructions at the beginning of the assignment. You may be penalized for incorrectly named files. Make sure there are no extra characters, such as spaces and underscores. The marker will run your programs and may change the canvas size and the values of the constants. It should still work if any constants are changed in a reasonable way. You may be significantly penalized if your program doesn't run, and substantially penalized if it does not work with different values. PAGE 4 OF 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

=+ (d) Even if F has jumps, E[ F(X)] ={ + E, P2[X=x].

Answered: 1 week ago

Question

7. Define cultural space.

Answered: 1 week ago

Question

8. Describe how cultural spaces are formed.

Answered: 1 week ago