Given the following code, select the correct option that can be used in place of the current empty draw() function.int sideLength = 100;int x = 0;int y = 0;void setup() { size(800, 800); x = width/2; y = height/2;}void draw() { // which option will work here?}float mapCoord(float a) { return 1.1 * a + 10;}float stretch(float coordinate, float len) { float scalingFactor = 1.1+coordinate/max(width,height); return len * scalingFactor;}void mousePressed() { x = mouseX; y = mouseY;}void mouseDragged() { x = mouseX; y = mouseY;}Question 3Answera.void draw() { background(200, 240, 200); fill(150, 200, 150); rect(mapCoord(x), mapCoord(y), stretch(x, sideLength), stretch(y, sideLength)); fill(0); rect(x, y, sideLength, sideLength);}b.void draw() { background(200, 240, 200); fill(150, 200, 150); rect(x, y, stretch(x), stretch(y)); fill(0); rect(x, y, sideLength, sideLength);}c.void draw() { background(200, 240, 200); fill(150, 200, 150); rect(mapCoord(x, y), mapCoord(y, x), sideLength, sideLength); fill(0); rect(x, y, sideLength, sideLength);}
Question
Given the following code, select the correct option that can be used in place of the current empty draw() function.int sideLength = 100;int x = 0;int y = 0;void setup() { size(800, 800); x = width/2; y = height/2;}void draw() { // which option will work here?}float mapCoord(float a) { return 1.1 * a + 10;}float stretch(float coordinate, float len) { float scalingFactor = 1.1+coordinate/max(width,height); return len * scalingFactor;}void mousePressed() { x = mouseX; y = mouseY;}void mouseDragged() { x = mouseX; y = mouseY;}Question 3Answera.void draw() { background(200, 240, 200); fill(150, 200, 150); rect(mapCoord(x), mapCoord(y), stretch(x, sideLength), stretch(y, sideLength)); fill(0); rect(x, y, sideLength, sideLength);}b.void draw() { background(200, 240, 200); fill(150, 200, 150); rect(x, y, stretch(x), stretch(y)); fill(0); rect(x, y, sideLength, sideLength);}c.void draw() { background(200, 240, 200); fill(150, 200, 150); rect(mapCoord(x, y), mapCoord(y, x), sideLength, sideLength); fill(0); rect(x, y, sideLength, sideLength);}
Solution
The correct option is:
a. void draw() { background(200, 240, 200); fill(150, 200, 150); rect(mapCoord(x), mapCoord(y), stretch(x, sideLength), stretch(y, sideLength)); fill(0); rect(x, y, sideLength, sideLength); }
This is because the functions mapCoord() and stretch() are used correctly in this option. mapCoord() is used to map the x and y coordinates and stretch() is used to stretch the side length of the rectangle based on the x and y coordinates. The other options either do not use these functions correctly or do not use them at all.
Similar Questions
b.void draw() { background(200, 240, 200); fill(150, 200, 150); rect(mapCoord(x), mapCoord(y), stretch(x, sideLength), stretch(y, sideLength)); fill(0); rect(x, y, sideLength, sideLength);}
Question: 3In a graphics canvas, what are the coordinates of the bottom right corner of the canvas?0, 0JavaScript0, getWidth()JavaScriptgetHeight(), getWidth()JavaScriptgetWidth(), getHeight()
Select the correct answerWhat will be the output of the following Java program? class shape { int breadth; int height; int area; void area() { area = 1/2 * breadth * height; } void area(int x) { area = x; } } class triangle { public static void main(String args[]) { shape obj = new shape(); obj.breadth = 4; obj.height = 4; obj.area(4); System.out.println(obj.area); } }Options04816
Question: 2In a graphics canvas, what are the coordinates of the center of the canvas?getWidth(), getHeight()JavaScriptgetWidth() / 2, getHeight() / 2JavaScriptgetHeight() - getWidth(), getWidth() - getHeight()JavaScriptgetHeight() / 2, getWidth() / 2
If a user enters a diameter value in the variable diameter, how would we use this to draw the correct sized circle?var circle = new Circle(diameter);circle.setPosition(100,100);add(circle);var circle = new Circle(diameter*2);circle.setPosition(100,100);add(circle);var circle = new Circle(diameter/2);circle.setPosition(100,100);add(circle);var circle = new Circle(diameter%2);circle.setPosition(100,100);add(circle);
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.