Write a method that takes a float w and draws a pair of


Assignment

Task 1

1) Write a method that draws a square such that the center of the square is the location of the mouse. This method does not need to take any inputs.

2) Write a method that takes an (x,y) position, and draws a pair of circles at that location: one smaller and the other larger, like this:

2054_Pair of Circle.jpg

3) Write a method that takes three ints: x, y, and c. It should then draw a rectangle at the location (x,y), that is a shade of grey based on c. If c is 0 it should be completely black, if c is 255 it should be completely white.

Task 2

1) Write a method that takes an (x,y) position, and draws a smiley face centered on that position. You may find the arc() method useful, but you can make the smiley face out of rectangles, ellipses, and lines if you want. It doesn't need to look great.

2) Write a method that takes four ints: x1, y1, x2, y2. It should then draw a rectangle with the top-left corner at (x1,y1), and the bottom right corner at (x2,y2). You can assume that (x2,y2) will always be down and to the right of (x1,y1).

3) Write a method that takes a float, w, and draws a pair of lines that cross at the location of the cursor. w is the total horizontal width of the X-shape that they make.

4) Write a method that takes 6 floats: x1,y1,x2,y2,x3,y3. It should then use the line() method to draw the three edges of a triangle that has corners at (x1,y1), (x2,y2), and (x3,y3). (It's interesting to note that this is basically the same as the triangle() method that is built into processing, except that you won't be adding the fill.)

Task 3

1) Write a method that takes 5 floats: x1, y1, x2, y2, and fraction. Assuming fraction is between 0 and 1, it should draw a circle centered that fraction of the way between (x1, y1) and (x2, y2). In other words, if fraction is 0, it should draw a circle at (x1, y1). If fraction is 1, it should draw a circle at (x2, y2). If fraction is 0.25, it should draw a circle one quarter of the way along an imaginary line that goes from (x1, y1) to (x2, y2). (Hint: the x position of the circle will only depend on the x values and fraction, so you might first start by thinking about it on just the x axis. This problem is fairly math- heavy.)

2) Write a method, pastel(), that takes 3 ints: r, g, and b, and sets the fill to a pastel version of that color. (A pastel color is simply a pale color. It might be worth playing around in the color selector or a drawing program to look for patterns in the r,g,b values of pale colors.) For example, pastel(255,0,0) should set the fill to pink, and pastel(0,255,255) should set the fill to light teal. It should not set the fill to completely white unless given values extremely close to 255. Write a second method colorNeg(), that takes 3 ints: r, g, and b, and sets the fill to the negative of that color. For example, colorNeg(0,0,0) should set the fill to white, and colorNeg(0,255,0) should set the fill to magenta.

1) Write a method that takes 6 integers: x1, y1, x2, y2, x3, y3. It should then draw three ellipses centered at those locations. It should always draw them so that ellipses further up and left are drawn on top. For example, you could draw the following set of circles with this method:

1650_Three Ellipses Centered.jpg

But not the same circles with the rightmost one on top. The leftmost circle is drawn on top of the one in the middle even though it's further down, because it's further left than it is down.

Solution Preview :

Prepared by a verified Expert
Computer Engineering: Write a method that takes a float w and draws a pair of
Reference No:- TGS02197467

Now Priced at $50 (50% Discount)

Recommended (95%)

Rated (4.7/5)