<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      canvas標(biāo)簽的width和height以及style.width和style.height的區(qū)別

      背景

        今天在博問中看到一個(gè)問題:用canvas 的 lineto方法畫對角線,但畫出來的圖形不對?

        這是一個(gè)很常見的誤區(qū),這里給大家細(xì)說一下。

      原理

        在w3網(wǎng)站上是這樣解釋的:

      The canvas element has two attributes to control the size of the coordinate space: width and height. These attributes, when specified, must have values that are valid non-negative integersThe rules for parsing non-negative integers must be used to obtain their numeric values. If an attribute is missing, or if parsing its value returns an error, then the default value must be used instead. The width attribute defaults to 300, and the height attribute defaults to 150.

      The intrinsic dimensions of the canvas element equal the size of the coordinate space, with the numbers interpreted in CSS pixels. However, the element can be sized arbitrarily by a style sheet. During rendering, the image is scaled to fit this layout size.

        其實(shí)這里已經(jīng)說的很明白,通俗點(diǎn)說就是在canvas中定義width、height跟在style中定義width和height是不同的,canvas標(biāo)簽的width和height是畫布實(shí)際寬度和高度,繪制的圖形都是在這個(gè)上面。而style的width和height是canvas在瀏覽器中被渲染的高度和寬度。如果canvas的width和height沒指定或值不正確,就被設(shè)置成默認(rèn)值(width:300px,height:150px)。

        我們可以利用style的width和height來縮放canvas,請看下面的示例。

      示例

        示例代碼如下:

      <!DOCTYPE html>
      <html>
      <head>
      <title>Demo</title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <script type="text/javascript">
      function drawDiagonal(id){
      var canvas=document.getElementById(id);
      var context=canvas.getContext("2d");
      context.beginPath();
      context.moveTo(
      0,0);
      context.lineTo(
      100,100);
      context.stroke();
      }

      window.onload
      =function(){
      drawDiagonal(
      "diagonal1");
      drawDiagonal(
      "diagonal2");
      drawDiagonal(
      "diagonal3");
      }
      </script>
      </head>
      <body>
      <canvas id="diagonal1" style="border:1px solid;" width="100px" height="100px"></canvas>
      <canvas id="diagonal2" style="border:1px solid;width:200px;height:200px;" width="100px" height="100px"></canvas>
      <canvas id="diagonal3" style="border:1px solid;width:200px;height:200px;"></canvas>
      </body>
      </html>
      posted @ 2012-02-28 18:23  artwl  閱讀(17889)  評論(5)    收藏  舉報(bào)

      個(gè)人簡介

      var ME = {
      	"name": "土豆/Artwl",
      	"job": "coding",
      	"languages": [
      		"JS", "HTML",
                      "CSS", "jQuery"
      		"MVC",".NET",
      		"設(shè)計(jì)模式"
      	],
      	"hobby": [
      		"閱讀", "旅游",
      		"音樂", "電影"
      	]
      }
      
      TOP
      主站蜘蛛池模板: 国产精品一码在线播放| 一区二区三区在线 | 欧洲| 亚洲成色精品一二三区| 国产丰满老熟女重口对白| 亚洲欧美色综合影院| 国产偷窥熟女精品视频大全| 久久人妻精品白浆国产| 欧洲亚洲国内老熟女超碰| 亚洲成人av在线资源| 成人亚欧欧美激情在线观看| 久久永久视频| 国内免费视频成人精品| 国产亚洲精品成人aa片新蒲金| 沂南县| 国产成人免费ā片在线观看| 男女扒开双腿猛进入爽爽免费看| 少妇一边呻吟一边说使劲视频| 免费看欧美日韩一区二区三区| 色综合久久人妻精品日韩| 人妻18毛片A级毛片免费看| 四虎永久播放地址免费| 深夜免费av在线观看| 国产目拍亚洲精品二区| 亚洲三区在线观看内射后入 | 九九热爱视频精品| 天堂网亚洲综合在线| 国产不卡精品一区二区三区| 亚洲国产成熟视频在线多多| 国产成人亚洲综合图区| 久久人人97超碰精品| 狠狠综合久久久久综| 亚洲人成网线在线播放VA| 成人免费视频一区二区三区| 日韩不卡无码精品一区高清视频| 鲁丝片一区二区三区免费| 高级艳妇交换俱乐部小说| 亚洲国产精品嫩草影院久久| 377P欧洲日本亚洲大胆| 思思99热精品在线| 国产乱子伦农村xxxx| 午夜免费福利小电影|