Question: Use Java Code (DrJava) The current coordinate system used by Turtle Graphics has the 'origin' in the centre of the canvas, at position (0,0). As
Use Java Code (DrJava)




The current coordinate system used by Turtle Graphics has the 'origin' in the centre of the canvas, at position (0,0). As the default size is a 300x300 canvas, that means coordinates go from (-150, -150) in the lower-right corner to (149,149) in the upper-right. Suppose we wanted the same canvas to be represented by a simpler system: The upper-left corner is (0,0) The lower-right corner is (29,29) . ONTOOONOOO OTOCONO0rrrrrrrrrr Imtioco N000) NOO 10 11 12 13) 14 15. 16. 17 18 19 20 21 22 23 24 27 28 29 If we wanted to draw with these coordinates, we'd simply need to translate the coordinates (add or subtract), and then scale (multiply) to get everything sized correctly. Your task is as follows: Write a method, drawPixel, that, when given an x,y coordinate for the system above, actually draws a square onto the TurtleDisplayer Use a pen width of 3 Write a method, drawLine, that when given x,y pixel coordinates, and a length, draws a horizontal line of pixels, starting at the requested position, with the requested length Write a method, drawBox, that receives x,y pixel coordinates of the upper-left corner of a box, and a width and height of the box It draws the box by drawing height horizontal lines, width across Write a method, drawval, that receives the x,y pixel coordinates of its centre, and draws an wide oval about that point The oval is 5 pixels tall, and 9 wide; refer to the diagram below o Draw the oval with a combination of lines and pixels Write a method, drawCloud that receives x,y pixel coordinates, and draws an oval at those coordinates, with a white pen o Yes, this one really is just changing the pen colour to white, and then calling drawOval with the same x,y coordinates Write a method, drawFlower, to receive an x,y and draw a flower with the base of its stem as rooted at those coordinates o e.g. in the above example, the flower is at 8,29 A flower is comprised of: A red oval . A yellow face Two red eyes . A green box of width 1 and height 5 for a stem Two green leaves (drawn as four pixels) Write a method, drawPipe, that accepts an x only (as its bottom will always be at 29) You can draw one as two green boxes, centred about the x position o e.g. the above pipe is at 21 Write a method, drawBackground, that just blanks the canvas to black Feel free to just set the pen's width to an absurdly large number and draw a few lines Write a method, drawScene, that draws two clouds, a pipe, a flower on the ground, and a flower on the pipe; all on top of the background If we wanted to draw with these coordinates, we'd simply need to translate the coordinates (add or subtract), and then scale (multiply) to get everything sized correctly. Your task is as follows: Write a method, drawPixel, that, when given an x,y coordinate for the system above, actually draws a square onto the TurtleDisplayer Use a pen width of 3 Write a method, drawLine, that when given x,y pixel coordinates, and a length, draws a horizontal line of pixels, starting at the requested position, with the requested length Write a method, drawBox, that receives x,y pixel coordinates of the upper-left corner of a box, and a width and height of the box It draws the box by drawing height horizontal lines, width across Write a method, drawval, that receives the x,y pixel coordinates of its centre, and draws an wide oval about that point The oval is 5 pixels tall, and 9 wide; refer to the diagram below o Draw the oval with a combination of lines and pixels Write a method, drawCloud that receives x,y pixel coordinates, and draws an oval at those coordinates, with a white pen o Yes, this one really is just changing the pen colour to white, and then calling drawOval with the same x,y coordinates Write a method, drawFlower, to receive an x,y and draw a flower with the base of its stem as rooted at those coordinates o e.g. in the above example, the flower is at 8,29 A flower is comprised of: A red oval . A yellow face Two red eyes . A green box of width 1 and height 5 for a stem Two green leaves (drawn as four pixels) Write a method, drawPipe, that accepts an x only (as its bottom will always be at 29) You can draw one as two green boxes, centred about the x position o e.g. the above pipe is at 21 Write a method, drawBackground, that just blanks the canvas to black Feel free to just set the pen's width to an absurdly large number and draw a few lines Write a method, drawScene, that draws two clouds, a pipe, a flower on the ground, and a flower on the pipe; all on top of the background For the main patterns in the scene: Since the cloud is just drawing an oval after setting the pen colour white, we'll define the oval: The blue dot is not drawn; it's just showing the origin of the oval/cloud For the pipe: Again, the blue dot shows the origin; everything else should be relative to that position (Of course, the y portion will always be treated as 29) The top piece can be a box, and the vertical portion can also be a box For the flower: The current coordinate system used by Turtle Graphics has the 'origin' in the centre of the canvas, at position (0,0). As the default size is a 300x300 canvas, that means coordinates go from (-150, -150) in the lower-right corner to (149,149) in the upper-right. Suppose we wanted the same canvas to be represented by a simpler system: The upper-left corner is (0,0) The lower-right corner is (29,29) . ONTOOONOOO OTOCONO0rrrrrrrrrr Imtioco N000) NOO 10 11 12 13) 14 15. 16. 17 18 19 20 21 22 23 24 27 28 29 If we wanted to draw with these coordinates, we'd simply need to translate the coordinates (add or subtract), and then scale (multiply) to get everything sized correctly. Your task is as follows: Write a method, drawPixel, that, when given an x,y coordinate for the system above, actually draws a square onto the TurtleDisplayer Use a pen width of 3 Write a method, drawLine, that when given x,y pixel coordinates, and a length, draws a horizontal line of pixels, starting at the requested position, with the requested length Write a method, drawBox, that receives x,y pixel coordinates of the upper-left corner of a box, and a width and height of the box It draws the box by drawing height horizontal lines, width across Write a method, drawval, that receives the x,y pixel coordinates of its centre, and draws an wide oval about that point The oval is 5 pixels tall, and 9 wide; refer to the diagram below o Draw the oval with a combination of lines and pixels Write a method, drawCloud that receives x,y pixel coordinates, and draws an oval at those coordinates, with a white pen o Yes, this one really is just changing the pen colour to white, and then calling drawOval with the same x,y coordinates Write a method, drawFlower, to receive an x,y and draw a flower with the base of its stem as rooted at those coordinates o e.g. in the above example, the flower is at 8,29 A flower is comprised of: A red oval . A yellow face Two red eyes . A green box of width 1 and height 5 for a stem Two green leaves (drawn as four pixels) Write a method, drawPipe, that accepts an x only (as its bottom will always be at 29) You can draw one as two green boxes, centred about the x position o e.g. the above pipe is at 21 Write a method, drawBackground, that just blanks the canvas to black Feel free to just set the pen's width to an absurdly large number and draw a few lines Write a method, drawScene, that draws two clouds, a pipe, a flower on the ground, and a flower on the pipe; all on top of the background If we wanted to draw with these coordinates, we'd simply need to translate the coordinates (add or subtract), and then scale (multiply) to get everything sized correctly. Your task is as follows: Write a method, drawPixel, that, when given an x,y coordinate for the system above, actually draws a square onto the TurtleDisplayer Use a pen width of 3 Write a method, drawLine, that when given x,y pixel coordinates, and a length, draws a horizontal line of pixels, starting at the requested position, with the requested length Write a method, drawBox, that receives x,y pixel coordinates of the upper-left corner of a box, and a width and height of the box It draws the box by drawing height horizontal lines, width across Write a method, drawval, that receives the x,y pixel coordinates of its centre, and draws an wide oval about that point The oval is 5 pixels tall, and 9 wide; refer to the diagram below o Draw the oval with a combination of lines and pixels Write a method, drawCloud that receives x,y pixel coordinates, and draws an oval at those coordinates, with a white pen o Yes, this one really is just changing the pen colour to white, and then calling drawOval with the same x,y coordinates Write a method, drawFlower, to receive an x,y and draw a flower with the base of its stem as rooted at those coordinates o e.g. in the above example, the flower is at 8,29 A flower is comprised of: A red oval . A yellow face Two red eyes . A green box of width 1 and height 5 for a stem Two green leaves (drawn as four pixels) Write a method, drawPipe, that accepts an x only (as its bottom will always be at 29) You can draw one as two green boxes, centred about the x position o e.g. the above pipe is at 21 Write a method, drawBackground, that just blanks the canvas to black Feel free to just set the pen's width to an absurdly large number and draw a few lines Write a method, drawScene, that draws two clouds, a pipe, a flower on the ground, and a flower on the pipe; all on top of the background For the main patterns in the scene: Since the cloud is just drawing an oval after setting the pen colour white, we'll define the oval: The blue dot is not drawn; it's just showing the origin of the oval/cloud For the pipe: Again, the blue dot shows the origin; everything else should be relative to that position (Of course, the y portion will always be treated as 29) The top piece can be a box, and the vertical portion can also be a box For the flower
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
