JavaScript Canvas Review 2

JavaScript Canvas Review 2

Assessment

Flashcard

Computers

9th - 12th Grade

Hard

Created by

Quizizz Content

FREE Resource

Student preview

quiz-placeholder

5 questions

Show all answers

1.

FLASHCARD QUESTION

Front

In the ctx.rect shape, which property of the shape is variable?

Back

Width of the rectangle

2.

FLASHCARD QUESTION

Front

If you want the rectangle to move horizontally, which of its properties should be equal to the variable x? Options: x, y, width, height

Back

x

3.

FLASHCARD QUESTION

Front

You are creating a drawing on a Canvas using JavaScript. You want to draw a circle. If your context is ctx, what method would you call to draw a circle?

Back

ctx.arc(x, y, radius, startAngle, endAngle);

4.

FLASHCARD QUESTION

Front

What function do you add to your code to execute the function draw every 20 ms in a JavaScript animation on Canvas? Options: setTimeout(draw, 20), requestAnimationFrame(draw), setInterval(draw, 20), draw();

Back

setInterval(draw, 20)

5.

FLASHCARD QUESTION

Front

What conditional statement do you write to multiply dx by -1 any time x is greater than 250 or less than 50? Options: if (x < 250 && x > 50) { dx *= -1; }, if (x == 250 || x == 50) { dx *= -1; }, if (x >= 250 || x <= 50) { dx *= -1; }, if (x > 250 || x < 50) { dx *= -1; }

Back

if (x > 250 || x < 50) { dx *= -1; }