Javascript Canvas Flashcard

Javascript Canvas Flashcard

Assessment

Flashcard

Computers

6th - 8th Grade

Hard

Created by

Wayground Content

FREE Resource

Student preview

quiz-placeholder

13 questions

Show all answers

1.

FLASHCARD QUESTION

Front

Where is the origin (0,0) located on the canvas?

Back

Top Left

Answer explanation

In math, it's the bottom left. But on the canvas, it's the top left.

2.

FLASHCARD QUESTION

Front

In which direction does the y coordinate increase?

Back

Moving from bottom to top

Answer explanation

Math and javascript are the same for the x coordinate. To the right is increasing for x in math and javascript.

But it's different for the y coordinate. In Javascript, going down is an increasing y coordinate.

3.

FLASHCARD QUESTION

Front

Which one of these represents a point that is 50 pixels to the right of the top left corner and 70 pixels lower than the top left corner? (70, 50), (50, -70), (50, 70), (70, -50)

Back

(50, 70)

Answer explanation

Left/right is the x coordinate, which is first. So 50, should go there. Up/down is the y coordinate, which comes second. So 70 should go there.

We don't really use negative coordinates in javascript. So those don't make much sense.

4.

FLASHCARD QUESTION

Front

Which one of these represents a point that is 80 pixels to the right of the top left corner and 100 pixels lower than the top left corner? (80, 80), (getWidth(), 100), (80, 20), (80, 100)

Back

(80, 100)

Answer explanation

getWidth() is for when we want to think of the coordinate as how far it is from the right edge. So that won't work.

This is the distance from the top left corner, which in javascript is (0, 0). So we really just need to put the left/right # of pixels in the first spot (the x coordinate) and the up/down # of pixels in the second spot (the y-coordinate).

5.

FLASHCARD QUESTION

Front

Which one of these represents a point that is 80 pixels to the left of the top right corner and 100 pixels lower than the top right corner? Options: (getWidth() - 100, 80), (getWidth() - 80, 100), (80, 100), (80, getHeight() - 100)

Back

(getWidth() - 80, 100)

Answer explanation

The top is normally where we measure the y coordinate from, so that doesn't need to change.

But we usually measure the x coordinate from the left. So measuring from the top right corner makes our lives more annoying. To count from the right, we first go all the way right using getWidth(). That sets the x coordinate all the way to the right side of the canvas.

But we wanted to go 80 pixels left of that, so we just subtract 80 from getWidth().

6.

FLASHCARD QUESTION

Front

Which one of these represents a point that is 210 pixels to the left of the bottom right corner and 140 pixels higher than the bottom right corner? Options: (getWidth() - 210, getHeight() - 140), (getWidth() + 210, getHeight() + 140), (getWidth(), getHeight()), (210, 140)

Back

(getWidth() - 210, getHeight() - 140)

Answer explanation

The top is normally where we measure the y coordinate from, so measuring from the bottom means we need to subtract from getHeight(). getHeight() represents going all the way to the bottom. So subtracting 140 from that take us 140 above the bottom.

Same idea for the x coordinate. We want to be 210 from right edge, so do getWidth() - 210.

7.

FLASHCARD QUESTION

Front

Back

Answer explanation

getWidth() is the full width of the canvas. So dividing it by two will go halfway.

Same idea for getHeight().

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?