HTML5使用canvas画图时,图片被自动放大模糊的问题.....
HTML5使用canvas画图在定义canvas的标签的时候,一般是要确定它的高和宽的。不过切记不要定义到样式里面去......否则,里面所画的图片会自动放大或者缩小。具体画图的JS就不贴了,就是用的drawImage( image , x , y )这个函数而已。悲剧的结果
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>JavaScript Platformer 1</title>
- <style type="text/css">
- #Map{
- border:1px solid #000;
- width:1000px;
- height:600px;
- }
- </style>
- </head>
- <body>
- <canvas id="Map" >Your browser does not support the canvas element.</canvas>
- </body>
修改之后的HTML
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>JavaScript Platformer 1</title>
- <style type="text/css">
- #Map{border:1px solid #000; }
- </style>
- </head>
- <body>
- <canvas id="Map" width="1000" height="600">Your browser does not support the canvas element.</canvas> 时,图片被自动放大模糊的问题.....
相关推荐
IT之家 2020-03-11
graseed 2020-10-28
zbkyumlei 2020-10-12
SXIAOYI 2020-09-16
jinhao 2020-09-07
impress 2020-08-26
liuqipao 2020-07-07
淡风wisdon大大 2020-06-06
yoohsummer 2020-06-01
chenjia00 2020-05-29
baike 2020-05-19
扭来不叫牛奶 2020-05-08
hxmilyy 2020-05-11
黎豆子 2020-05-07
xiongweiwei00 2020-04-29
Cypress 2020-04-25
冰蝶 2020-04-20