Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program : processing 3.5.3 python mode Question 3 (7 points): Purpose: Practice using functions with return values in expressions as both operands and arguments Degree

image text in transcribedimage text in transcribedProgram : processing 3.5.3 python mode

Question 3 (7 points): Purpose: Practice using functions with return values in expressions as both operands and arguments Degree of Difficulty: Moderate Bertha the bug has been trapped in a box! The objective of this question is to model Bertha's unfortunate circumstance by drawing it on the canvas. Recall the 'Functions with Output' lecture exercise which we drew a yellow circle that followed the mouse within an area. In the exercise, a blue rectangle represented a border we were not allowed to draw the circle within. This question is an extension which adds borders to the top, bottom, and right side. Figure 3: A 50-pixel brown border surrounds the drawable portion of a 400 x 300 pixel canvas. Bertha is drawn at the upper-rightmost edge of the drawable area, meaning the mouse is either exactly at the edge of the border or beyond it. You may use the starter code, or your solution, from the lecture slides as a starting point. Model Bertha the bug as a circle that is 50 pixels in diameter. Bertha's body should be red with at least 5 black dots on her back. She should have a black face with two white eyes. Feel free to add more detail to Bertha if you would like but ensure these essential components are included. Model the box by setting the background and borders to some shade of brown. The borders represent the box walls and are an undrawable area 50 pixels thick from the sides of the canvas. 5 diameter = 50 6 left_border = 50 8 def setup(): size(300,300) 11 def circle_radius (diameter): return diameter/2 12 13 14 def circle_x(x, diameter, left_border): 15 return max(x, left_border + circle_radius (diameter)) def draw(): global left_border, diameter background (0,0,0) fill(0,0,255) rect(0,0,left_border,height) fill(255,255,0) ellipse(circle_x(mouseX, diameter, left_border),mousey, diameter, diameter)

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

Students also viewed these Databases questions