Graphics Questions and Answers Rated
A+
What function is used to take user input in CodeHS JavaScript?
✔✔ The `readLine()` function is used for text input, and `readInt()` or `readFloat()` for
numerical input.
How do you display a circle on the canvas in CodeHS JavaScript?
✔✔ Use `var circle = new Circle(radius);`, then `add(circle);` to display it.
What function sets the position of a shape on the canvas?
✔✔ The `setPosition(x, y);` function moves a shape to specific coordinates.
How can you change the color of a rectangle in CodeHS JavaScript?
✔✔ Use `setColor(Color.RED);` or another color from the `Color` library.
What function is used to pause the execution of a CodeHS JavaScript program temporarily?
✔✔ The `pause(milliseconds);` function delays execution for the given time.
1
, How do you get a user to enter their name in CodeHS JavaScript?
✔✔ Use `var name = readLine("Enter your name: ");`.
What function is used to change the size of a text label?
✔✔ The `setFont("30pt Arial");` function adjusts the text size and font.
How do you draw a line from the top-left to the bottom-right of the canvas?
✔✔ Create a `Line` object with `new Line(0, 0, getWidth(), getHeight());` and add it to the
canvas.
How do you clear all objects from the canvas?
✔✔ Use `removeAll();` to delete everything on the canvas.
How do you move a rectangle 10 pixels to the right?
✔✔ Use `rectangle.move(10, 0);`.
How do you set the background color of the canvas?
2