效果

作者: 洛洛kkkkkk | 来源:发表于2017-04-20 19:28 被阅读0次
<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            #myCanvas {
                border: 10px solid red;
                /*canvas的宽和高不能在样式表里设置*/
            }
        </style>
    </head>

    <body>
        <canvas id="myCanvas" width="600" height="600"></canvas>
    </body>
    <script type="text/javascript">
        var myCanvas = document.getElementById("myCanvas");

        var context = myCanvas.getContext("2d");
        var arr=["red","blue","black","yellow"]
        var deg = Math.PI/180;
//      for(var i = 0; i < 4; i++) {
//          context.beginPath();
//          context.moveTo(50+i*20, 50+i*20);
//          context.lineTo(50+i*20, 300+i*20);
//          context.lineTo(300+i*20, 300+i*20);
//          context.lineTo(300+i*20, 50+i*20);
//          context.strokeStyle = arr[i];
//          context.fillStyle=arr[i];
//          context.fill();
//          context.closePath();
//          context.lineWidth = 2;
//          context.stroke();
//      }
//      context.strokeStyle = arr[0];
//      context.strokeRect(50,50,200,100);//x,y,w,h

//      context.fillStyle=arr[0];
//      context.fillRect(50,50,200,100);


//      context.lineWidth = 50;
//      context.strokeStyle = "black";
//      context.strokeRect(50,50,200,200);
//      context.fillStyle = "red";
//      context.fillRect(50,50,200,200);

        //圆形的绘制
        //圆心x,y,半径,开始角度,结束,顺/逆时针(角度采用弧度)
//      context.beginPath();
//      context.lineWidth=20;
//      context.strokeStyle = "black";
//      context.arc(300,300,100,0,360*deg,true);
//      context.fillStyle = "royalblue";
//      context.fill();
//      context.stroke();
        
        //字体的绘制
//      context.font="100px Arial";
////        context.strokeStyle = "red";
////        context.strokeText("Hello",100,100);
////        
////        context.fillStyle = "#007AFF";
////        context.fillText("world",200,200);
//
//      //渐变
//      
//      var gradient = context.createLinearGradient(0,0,400,0);//开始坐标,结束坐标
//      gradient.addColorStop(0,"red");
//      gradient.addColorStop(0.5,"green");
//      gradient.addColorStop(1,"blue");
//      
//      context.fillStyle = gradient;
////        context.fillRect(0,0,600,600);
//      context.fillText("hellow world",0,100);

//      var gradient = context.createRadialGradient(300,300,0,300,300,300);
//      gradient.addColorStop(0,"pink");
//      gradient.addColorStop(0.2,"lightgoldenrodyellow");
//      gradient.addColorStop(1,"orange");
//      
//      context.fillStyle = gradient;
//      context.fillRect(0,0,600,600);

        //阴影
//      context.font="70px Arial";
//      context.shadowColor = "#00BFFF";
//      context.shadowBlur = 30;
//      context.shadowOffsetX = 10;
//      context.shadowOffsetY = 10;
//      context.fillStyle = "burlywood";
//      context.fillText("hellow world",50,100);
        
        
    </script>

</html>

相关文章

  • CAReplicatorLayer

    效果一 效果二 效果三 效果四 效果五 效果六 效果七 效果八 效果九

  • 简书 Markdown 编辑器丨文字颜色详解

    效果: 代码: 效果: 代码: 效果: 代码: 效果: 代码: - ### 效果: 代码: 效果: 代码: 效果:...

  • MarkDown 合并表格

    效果: 效果: 效果: 效果:

  • CGRectInset、CGRectOffset、UIEdgeI

    效果: 效果: 效果:

  • 北京王府井整体效果

    1.门头效果 门头效果 美家店邻铺效果(昨晚效果,未拆时) 1区效果 1区效果 2区整体效果 2区效果 3区效果 ...

  • CoreAnimation的粒子效果

    粒子效果 效果1 代码实现 效果2 代码实现 效果3 效果4 代码实现

  • 效果

    今天儿子午睡后醒来,我还在绞尽脑汁的马字,那个累呀。 儿子又想抢我的手机了,因为手机里有他喜欢的游戏,还有他...

  • 效果

  • 效果

    2、 感受老麻雀的勇敢无畏 教师深情地引入:“当猎狗张开大嘴,准备扑向小麻雀的时候。为了拯救自己的幼儿,老麻雀不顾...

  • 效果

    昨天晚上, 因为儿子不在家, 我听完魏森老师的直播课, 就迷迷糊糊的犯困了。 可是心里惦记着儿子, 不知道他第一次...

网友评论

      本文标题:效果

      本文链接:https://www.haomeiwen.com/subject/ozolzttx.html