NEW
Font size
S
M
L
XL
WorksheetsAnimated Canvas
Total questions: 19
Worksheet time: 38mins
Name
Class
Date
1.
This type of variable can be used throughout the entire program that you are writing.
a)
Global Variable
b)
Integer Variable
c)
Character Variable
d)
String Variable
2.
The context object is signified by ctx in almost all of the code that we've written. Context object means the part of the code that provides all the methods and preperties needed to paint shapes and text in the canvas area.
a)
True
b)
False
3.
Why would we make w=canvas.width; a global variable?
a)
It's easier to insert w continously into your code rather than canvas.width over and over again.
b)
You can't use canvas.width in the middle of a shape command.
c)
It's not a global variable because it's only for one function.
d)
It's the only way we can use canvas.width
4.
|| means
a)
OR
b)
AND
c)
IF
d)
ELSE
5.
&& means
a)
AND
b)
OR
c)
IF
d)
ELSE
6.
setInterval(position,25);
What is the time interval for the above instruction that calls a function?
What is the time interval for the above instruction that calls a function?
a)
25 milliseconds
b)
25 seconds
c)
25 years
d)
25 microseconds
7.
Is it possible to have multiple functions within a function?
a)
Yes
b)
No
8.
The variable x is more often than not the indicator of what?
a)
x coordinate
b)
y coordinate
c)
the width
d)
the height
9.
The variable y is more often than not the indicator of what?
a)
x coordinate
b)
y coordinate
c)
the width
d)
the height
10.
The variable h is more often than not the indicator of what?
a)
x coordinate
b)
y coordinate
c)
the width
d)
the height
11.
The variable w is more often than not the indicator of what?
a)
x coordinate
b)
y coordinate
c)
the width
d)
the height
12.
What is var dx used to indicate?
a)
direction step size
b)
x position
c)
canvas height
d)
background color
13.
What is var dy used to indicate?
a)
direction step size
b)
y position
c)
canvas width
d)
border color
14.
What is the function paint() used for?
a)
It clears the canvas and actually paints the ball at the currently stored XY coordinates.
b)
It paints the ball on top of itself over and over again.
c)
It allows you to paint the ball with your mouse.
d)
It calculates the position of the ball.
15.
What does function position() do?
a)
It calculates new XY coordinates and stores them in global variables - after it calls a function to paint the ball.
b)
It clears the canvas and actually paints the ball at the current stored XY coordinates.
c)
It intializes a context object property and applies styles as soon as the HTML document loads.
d)
It initializes the global variables with XY coordinates for the starting position of a "ball."
16.
What does function init() do?
a)
It calculates new XY coordinates and stores them in global variables - after it calls a function to paint the ball.
b)
It clears the canvas and actually paints the ball at the current stored XY coordinates.
c)
It intializes a context object property and applies styles as soon as the HTML document loads.
d)
It initializes the global variables with XY coordinates for the starting position of a "ball."
17.
What is the purpose of ctx.clearRect(0,0,w,h); ?
a)
It draws a small clear rectangle for you to animate.
b)
It clears the canvas for your painting.
c)
It creates a circle.
d)
It draws a small colored rectangle for you to animate.
18.
What does x += dx; mean?
a)
x = dx + x
b)
dx = dx + x
c)
x = dx - x
d)
dx = dx - x
19.
What does
(x+dx>w) || (x+dx<0) mean?
(x+dx>w) || (x+dx<0) mean?
a)
It means that code will start if x + dx is greater than w OR x + dx is less than 0
b)
It means that code will start if x + dx is greater than w AND x + dx is less than 0
Reset
