HTML and CSS Reference
In-Depth Information
context
.
setTransform
(
1
,
0
,
0
,
1
,
0
,
0
)
context
.
translate
(
x
+
16
,
y
+
16
);
var
var
angleInRadians
=
rotation
*
Math
.
PI
/
180
;
context
.
rotate
(
angleInRadians
);
var
var
sourceX
=
Math
.
floor
(
animationFrames
[
frameIndex
]
%
8
)
*
32
;
var
var
sourceY
=
Math
.
floor
(
animationFrames
[
frameIndex
]
/
8
)
*
32
;
context
.
drawImage
(
tileSheet
,
sourceX
,
sourceY
,
32
,
32
,
-
16
,
-
16
,
32
,
32
);
context
.
restore
();
}
function
function
eventShipLoaded
() {
drawScreen
();
}
Figure 4-8
shows the output for this example.