HTML and CSS Reference
In-Depth Information
function
function
drawScreen
() {
//Background
context
.
globalAlpha
=
1
;
context
.
shadowColor
=
"#707070"
;
context
.
shadowOffsetX
=
0
;
context
.
shadowOffsetY
=
0
;
context
.
shadowBlur
=
0
;
context
.
fillStyle
=
"#ffffaa"
;
context
.
fillRect
(
0
,
0
,
theCanvas
.
width
,
theCanvas
.
height
);
//Box
context
.
strokeStyle
=
"#000000"
;
context
.
strokeRect
(
5
,
5
,
theCanvas
.
width
-
10
,
theCanvas
.
height
-
10
);
//Text
context
.
textBaseline
=
textBaseline
;
context
.
textAlign
=
textAlign
;
context
.
font
=
fontWeight
+
" "
+
fontStyle
+
" "
+
fontSize
+
"px "
+
fontFace
;
context
.
shadowColor
=
shadowColor
;
context
.
shadowOffsetX
=
shadowX
;
context
.
shadowOffsetY
=
shadowY
;
context
.
shadowBlur
=
shadowBlur
;
context
.
globalAlpha
=
textAlpha
;
var
var
xPosition
=
(
theCanvas
.
width
/
2
);
var
var
yPosition
=
(
theCanvas
.
height
/
2
);
var
var
metrics
=
context
.
measureText
(
message
);
var
var
textWidth
=
metrics
.
width
;
var
var
tempColor
;
iif
(
fillType
==
"colorFill"
) {
tempColor
=
textFillColor
;
}
else
else iif
(
fillType
==
"linearGradient"
) {
var
gradient
=
context
.
createLinearGradient
(
xPosition
-
textWidth
/
2
,
yPosition
,
textWidth
,
yPosition
);
gradient
.
addColorStop
(
0
,
textFillColor
);
gradient
.
addColorStop
(.
6
,
textFillColor2
);
tempColor
=
gradient
;
}
else
var
else iif
(
fillType
==
"radialGradient"
) {
var
var
gradient
=
context
.
createRadialGradient
(
xPosition
,
yPosition
,
fontSize
,
xPosition
+
textWidth
,
yPosition
,
1
);
gradient
.
addColorStop
(
0
,
textFillColor
);
gradient
.
addColorStop
(.
6
,
textFillColor2
);
tempColor
=
gradient
;