

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A series of questions and answers related to javascript programming, specifically focusing on graphics and canvas manipulation. It covers topics such as drawing circles, setting positions, colors, and adding elements to the screen. The questions test understanding of basic javascript concepts and their application in graphical contexts, making it a useful resource for students learning javascript graphics. It also includes questions about anchor points and text objects.
Typology: Exams
1 / 3
This page cannot be seen from the preview
Don't miss anything!


The following program should draw a circle on the screen: 1 function main(){ 2 let circle = new Circle(40); 3 circle.setPosition(getWidth() / 2, getHeight() / 2); 4 circle.setColor("blue"); 5 } main(); But when we run this code, we don't see the circle. What is missing from our main function? We never set the circle's radius. We need to add the line circle.setRadius(40); After line 4 We are setting the position of the ball to be off the canvas.We need to change line 3 to be circle.setPosition(0, 0); We are creating the circle incorrectly. We need to specify the width and height.We need to change line 2 to be let circle = new Circle(40, 40); We create the circle and position it correctly on the screen, but we never add it to the screen.We need to add the line add(circle); JavaScript after line 4
We create the circle and position it correctly on the screen, but we never add it to the screen.We need to add the line add(circle); JavaScript after line 4 What function do you need to call to get the width of the canvas? width(); getWidth(); canvasWidth(); getCanvasWidth(); getWidth(); Where is the anchor point of a circle located? Left edge Right edge Center Top edge Bottom edge Center Where is the anchor point of a rectangle located? Top left corner Top right corner Center Bottom left corner Bottom right corner Top left corner consider the following code of a circle: 1 let circ = new Circle(50); 2 circ.setPosition(200, 200); 3 circ.setColor("blue"); 4 add(circ); JavaScript If we wanted to move the circle 10 pixels to the left, what change would we need to make? Add 10 to line 1: 1 let circ = new Circle(60); 2 circ.setPosition(200, 200); 3 circ.setColor("blue"); 4 add(circ); Subtract 10 from the first number on line 2: