Can you please show how to code using processing? Draw a table fan that looks similar to
Fantastic news! We've Found the answer you've been seeking!
Question:
Can you please show how to code using processing?
Transcribed Image Text:
Draw a table fan that looks similar to the one on the right. Use colours of your own choice. You should use variables. Your sketch should meet the following criteria: • Draw a table fan similar to the one shown here but with different colours. Use a canvas size of 500 by 500. It should have the following: o A central disc, of a solid color. Three propellers, equally spaced • At least three concentric circles to draw a fan cover as shown in Figure 1. Use final named constants to set the following Cover size and central disc size. o • A speed value to control the rotation speed. Use the primitive data type float. You are required to create the following functions 。 setup() 。 draw() 。 drawFan() 。 rotateFan() Figure 1: Table Fan • Try to keep the fan at the center of the canvas at all times. Q2: Modify Q1 to add a speed controller to change the fan speed with mouse clicks. [10 Marks] Take the code you created in Q1 and modify it to achieve the following. • Draw a speed controller as shown in Figure 2. It should consist of three sections: a + button to increase the fan speed, a- button to decrease the speed, and a speed display. The speed controller will provide 6 speed options (0 to 5). The fan should be still at speed 0 and rotating at the maximum speed at setting 5. When the program begins, the fan should not be rotating and the speed should be 0. • When the user clicks on the + button, the speed should increase by 1 on the display and the rotation speed should change accordingly. The speed should only increase to 5 after which clicking on + should not do anything Clicking on the button should decrease the speed by one. The speed should only decrease to 0 at which time the fan should stop moving. You should define the special function void mouseClicked() which will be run automatically every time the user clickes the mouse button in the canvas. This is a special function in Processing just as setup() and draw() are. Do not call mouseClicked in your code! Figure 2: Table fan with speed controller Draw a table fan that looks similar to the one on the right. Use colours of your own choice. You should use variables. Your sketch should meet the following criteria: • Draw a table fan similar to the one shown here but with different colours. Use a canvas size of 500 by 500. It should have the following: o A central disc, of a solid color. Three propellers, equally spaced • At least three concentric circles to draw a fan cover as shown in Figure 1. Use final named constants to set the following Cover size and central disc size. o • A speed value to control the rotation speed. Use the primitive data type float. You are required to create the following functions 。 setup() 。 draw() 。 drawFan() 。 rotateFan() Figure 1: Table Fan • Try to keep the fan at the center of the canvas at all times. Q2: Modify Q1 to add a speed controller to change the fan speed with mouse clicks. [10 Marks] Take the code you created in Q1 and modify it to achieve the following. • Draw a speed controller as shown in Figure 2. It should consist of three sections: a + button to increase the fan speed, a- button to decrease the speed, and a speed display. The speed controller will provide 6 speed options (0 to 5). The fan should be still at speed 0 and rotating at the maximum speed at setting 5. When the program begins, the fan should not be rotating and the speed should be 0. • When the user clicks on the + button, the speed should increase by 1 on the display and the rotation speed should change accordingly. The speed should only increase to 5 after which clicking on + should not do anything Clicking on the button should decrease the speed by one. The speed should only decrease to 0 at which time the fan should stop moving. You should define the special function void mouseClicked() which will be run automatically every time the user clickes the mouse button in the canvas. This is a special function in Processing just as setup() and draw() are. Do not call mouseClicked in your code! Figure 2: Table fan with speed controller
Expert Answer:
Answer rating: 100% (QA)
Q1 the variable deg stores the current degree of rotation of fanwings final int radius 40 float deg 30 void setup size500 500 void draw background255 ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Problem A (20 points): Loco Farms Company sold 36,000 units of its only product and incurred a $18,672 loss (ignoring taxes) for the current year as shown here. During a planning session for year...
-
Three uniform metersticks, each of mass m, are placed on the floor as follows: stick 1 lies along the y axis from y = 0 to y = 1.0 m, stick 2 lies along the x axis from x = 0 to x = 1.0 m, stick 3...
-
In Exercises find the indefinite integral. e2r ex - e-2x ex + e-2x dx
-
What do you know about the mathematical value of a project's internal rate of return under each of the following conditions? a. The present worth of the project is greater than 0 . b. The present...
-
Reconstructing the income statement and balance sheet (Adapted from a problem by Stephen A. Zeff) Portobello Co., a retailer, is in its 10th year of operation. On December 28, 2008, three days before...
-
Discuss the differences between (Data Definition Language) DDL and (Data Manipulation Language) DML using SQL example.?
-
Tracey White, the owner of the Buzz Coffee Shop chain, has decided to expand her operations. Her 2012 financial statements follow. Tracey can buy two additional coffeehouses for $3 million, and she...
-
Explain the relationship between strategic management and competitive advantage for firms. How can a firm achieve sustained competitive advantage?
-
. Calculate the total resistance of a circuit where a fan (2 ohms) and 4 lights (1 ohm each) are all connected in parallel. O 6.00 3.00 0.150 0.22 0
-
If the hub gear and the ring gear R have angular velocities @ (rad/s) and WR (rad/s), respectively, determine the angular velocity ws (rad/s) of the spur gear S? 1 a. w = (-5w +3wH) 2 1 b. == (5WR +...
-
-0 Compute det B, where B = 01 1 12 2 1
-
The monochromatic emissivity of a diffuse-surface at 1600 K varies with wavelength in the following manner : = 0.4 for 0
-
Fig. 4.45 shows a one-arm device caliper and a three-arm bow-spring device caliper obtained in the same borehole in- terval. Explain the disagreement between the two logs in both the thick and thin...
-
In the given circuit R6 is equal to 6 omega and in the state of an open circuit breaker: V1 = 55V, V2 = 30V. A. Calculate R1. B. What does V3 show when the circuit breaker is open. When the circuit...
-
Given the table below, about how much force does the rocket engine exert on the 4.0 kg payload? Distance traveled with rocket engine firing (m) Payload final velocity (m/s) 500 320 490 310 1020 450...
-
Under what circumstances will the conversion predicted by mass transfer limitations be greater than that for surface reaction limitations?
-
A first-order heterogeneous irreversible reaction is taking place within a spherical catalyst pellet that is plated with platinum throughout the pellet. The reactant concentration halfway between the...
-
The dehydration of butanol is carried out over a silica-alumina catalyst at 680 K. CH3CH2CH2CH2OHcatCH3CH=CHCH3+H2O The rate law is rBu=kPBu(1+KBuPBu)2 with k = 0.054 mol/gcathatm and K Bu = 0.32 atm...
-
An MMW side looking SAR has the following specifications: radar velocity v = 70 m/s, elevation angle = 35, operating frequency f0 = 94 GHz, and antenna 3 dB beam width 3dB = 65 mrad. (a) Calculate...
-
Consider a synthetic aperture radar. You are given the following Doppler history for a scatterer: {1000 Hz, 0, 1000 HZ}, which corresponds to times {10 ms, 0, 10 ms}. Assume that the observation...
-
A side looking SAR takes on eight positions within an observation interval. In each position, the radar transmits and receives one pulse. Let the distance between any two consecutive antenna...
Study smarter with the SolutionInn App