• [ html 绘图 translate roteta ] canvas绘图属性translate 设置画布中心点 rotate 旋转属性实例演示


    <!DOCTYPE html>
    <html lang='zh-cn'>
    <head>
    <title>Insert you title</title>
    <meta name='description' content='this is my page'>
    <meta name='keywords' content='keyword1,keyword2,keyword3'>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel='stylesheet' type='text/css' href='./css/index.css' />
    <script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
    <style type='text/css'>
    html,body {
        margin: 0; padding: 0;
    }
    
    html {
        background: #999; height: 100%;
    }
    
    #can {
        background: #FFF; display: block; margin: 75px auto; border-radius: 2px;
    }
    </style>
    <script type='text/javascript'>
        $( function(){
            var oCan = $( '#can' ).get( 0 ).getContext( '2d' );
            oCan.beginPath();
            /* translate rotate 这两个属性要设置在moveTo lineTo 之前,否则无效 */
            oCan.translate(125,50);    /* 改变画布的中心 */
            oCan.rotate(15*Math.PI/180);    /* 旋转是围绕画布的中心点进行的, */
            oCan.moveTo( 30 , 120 );
            oCan.lineTo( 120 , 30 );
            oCan.lineWidth = 1;
            oCan.strokeStyle = '#F00';
            
            oCan.stroke();
            oCan.closePath();
        } );
        function getId( id ){
            return document.getElementById( id );
        }
    </script>
    </head>
    <body>
        <canvas id='can' width='500' height='500'>您的浏览器版本过低,请您更换浏览器以获取更好的用户体验...</canvas>
    </body>
    </html>
  • 相关阅读:
    Java实现蓝桥杯正则切分
    VS2013 预定义的宏
    VS2015编译boost1.62
    linux 下Qt WebEngine 程序打包简单记录
    Visual Studio 默认保存为UTF8编码
    微型Http服务器Tiny Http Server
    Bootstrap Paginator分页插件
    Web前端框架与类库
    开发与常用工具清单
    程序员修炼之道
  • 原文地址:https://www.cnblogs.com/mysearchblog/p/5760496.html
Copyright © 2020-2023  润新知