HTML Canvas Transformation Lecture Review

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/12

flashcard set

Earn XP

Description and Tags

A set of practice flashcards covering HTML Canvas transformation methods including save, restore, translate, rotate, and scale based on lecture notes.

Last updated 2:40 PM on 5/18/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

13 Terms

1
New cards

Which two indispensable methods help in creating complex drawings in HTML Canvas?

save() and restore()

2
New cards

What is the purpose of the ctx.save() method?

It saves the entire current state of the Canvas element by pushing it onto a stack.

3
New cards

What does the ctx.restore() method do?

It rollbacks the last saved canvas state by popping it off the stack.

4
New cards

How many times can the save() method be called?

It can be called as many times as the user needs, with each state being pushed into the stack.

5
New cards

In what three scenarios is using save() recommended?

When temporarily changing styles, applying transformations (rotate, scale, translate), or wishing to avoid manually resetting properties.

6
New cards

What does the translate(x, y) method accomplish?

It moves the canvas origin and the grid to another position, where xx is the horizontal distance and yy is the vertical distance.

7
New cards

In what unit must the angle be passed to the rotate(angle) method?

Radians

8
New cards

What is the formula to convert degrees to radians in the context of Canvas?

radians=degrees×Math.PI180\text{radians} = \text{degrees} \times \frac{\text{Math.PI}}{180}

9
New cards

Where does rotation occur by default in the Canvas coordinate system?

Rotation happens around the origin (0,0)(0,0).

10
New cards

What is the recommended sequence of commands to rotate an object properly around a specific pivot point?

1.1. ctx.save(); 2.2. ctx.translate(centerX, centerY); 3.3. ctx.rotate(angle); 4.4. ctx.fillRect(-width/2, -height/2, width, height); 5.5. ctx.restore();

11
New cards

What is the purpose of the scale(x, y) method?

It is used to increase or decrease the size of the Canvas grid by modifying the unit size.

12
New cards

By default, how much is one unit of the canvas element valued at?

Exactly 1pixel1\,\text{pixel}.

13
New cards

In the scale(x, y) method, what is the difference between values less than 1.0 and more than 1.0?

Values less than 1.01.0 reduce the unit size, while values more than 1.01.0 increase the unit size.