Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Draw an animal Develop non-active Processing program (containing no setup() or draw() functions) that will draw an animal on the canvas, with or without a

Draw an animal Develop non-active Processing program (containing no setup() or draw() functions) that will draw an animal on the canvas, with or without a frame around it. based on the following rules: Follow the Shape Dependency Model Include 6 to 16 shapes (ellipses, rectangles, lines or other shapes). 14 shapes (12 ellipses, 1 line and a rectangle for the frame). Your script must contain: o at least one ellipse, o at least one rectangle (this can be, but doesn't have to be, a frame around your animal) o at least one line, triangle or quad (shapes defined only by coordinates) It should contain at least 3 different colors. It can be a pretty basic animal, even more, basic than the one shown. You must use a 500 x 500 canvas for this question. you are going to scale the animal in the horizontal and vertical directions. Because of this, you should avoid using circles/squares and instead only use ellipses and rectangles. The animal must be medium to large and use up a good proportion of the canvas, It should be roughly centered in the window. your animal will move, grow, and shrink. To make that easier, you MUST develop code following the shape dependency model. In the shape dependency model, you choose one shape as the root or parent shape. You define its size and its position using constants. Then, every other shape is defined in relation to the first (root or parent) shape, either directly or indirectly. This way, if you move the root shape's position, all the other shapes follow along automatically. Also, if you make the root shape bigger or smaller in either the X or Y dimension (or both), the other shapes will also scale appropriately. Define constants for your root shape. These can depend on the canvas width and height. Hint: use a rectangle or ellipse as the root shape of your animal, since they have both position coordinates and separate horizontal and vertical dimensions (width and height). Shapes that are only defined by coordinates (lines, triangles, quads) are fine to add to your animal, but using one of those for the root shape would make the code MUCH more difficult. For the rest of your shapes, you can use variables. But these must all depend on the width, height and coordinates of your root shape (not the canvas width and height). Your drawing commands (like rect(...), ellipse(...) etc. should only contain constants or variable names, no numbers. The variables you create can be defined using other constants and variables combined with simple numbers like 2, 3, 4, 5, 6, 7 or 8 to get sizes that are divisions or multiplications relative to other body parts. For example, you can have something like this: leftEyeX = headX - headWidth/3; ellipse(leftEyeX, ....) Use good, descriptive variable names that highlight the difference between locations and dimensions (leftEyeX, which tells where the left eye is, vs. eyeWidth, which says how wide the eye is). Every shape you draw will need at least a few variables defined for it. Pay attention to when you can reuse variables. For example, eyes are both at the same height, we need leftEyeX, rightEyeX and eyeY (only one variable for eye height is needed). Save a copy of your original Question 1 program

Convert your program into an Active Processing program, with the animal centered on the canvas , follow these instructions: 1. Create the usual setup()and draw() functions. Create drawAnimal() function (or a similar name). 2. Move all of your existing code from Question 1 into the appropriate place in these new functions. All of the code that draws your animal should go into the drawAnimal() function, not into the draw() function directly. The functions should call each other as needed. 3. You will need to change the two constants that define the position of the root shape into global variables. 4. Create moveAnimal() function (or use a similar name). The moveAnimal() function should use the mouse cursor position to set the X and Y values for the location of your animal. The center point of your animal's root shape should always exactly match the mouse cursor position. If you have followed the instructions in Question 1 carefully, following the shape dependency model, all the parts of your animal should move together, underneath the cursor.

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions