首页 > 其他 > 详细

WaterDrop

时间:2016-03-15 00:15:44      阅读:284      评论:0      收藏:0      [点我收藏+]

1、

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<style type="text/css">

#div01
{
    width:800px;
    height:600px;
    background:url(‘lake02.jpg‘) no-repeat;
    background-size:100%;
}

</style>

<script type="text/javascript" >

    window.onload = function()
    {
    // http://www.365mini.com/page/html5-canvas-circle.htm
        //获取Canvas对象(画布)
        var canvas = document.getElementById("myCanvas");
        //简单地检测当前浏览器是否支持Canvas对象,以免在一些不支持html5的浏览器中提示语法错误
        if(canvas.getContext)
        {  
            //获取对应的CanvasRenderingContext2D对象(画笔)
            var ctx = canvas.getContext("2d");  
            
            //ctx.lineWidth = 0.5;

            //开始一个新的绘制路径
            ctx.beginPath();
            //设置弧线的颜色为蓝色
            ctx.strokeStyle = "blue";
            var circle = {
                x : 100,    //圆心的x轴坐标值
                y : 100,    //圆心的y轴坐标值
                r : 50      //圆的半径
            };
            //沿着坐标点(100,100)为圆心、半径为50px的圆的顺时针方向绘制弧线
            ctx.arc(circle.x, circle.y, circle.r, 0, Math.PI / 2, false);    
            //按照指定的路径绘制弧线
            ctx.stroke();

        // http://www.w3school.com.cn/tags/canvas_clearrect.asp
            //ctx.clearRect(100, 100, 50, 50);
            //ctx.rect(100, 100, 50, 50);
            //ctx.stroke();
            ctx.clearRect(100, 100, 50, 50);

            //开始一个新的绘制路径
            ctx.beginPath();
            //设置弧线的颜色为蓝色
            ctx.strokeStyle = "blue";
            var circle01 = {
                x : 200,    //圆心的x轴坐标值
                y : 200,    //圆心的y轴坐标值
                r : 50      //圆的半径
            };
            //沿着坐标点(100,100)为圆心、半径为50px的圆的顺时针方向绘制弧线
            ctx.arc(circle01.x, circle01.y, circle01.r, 0, Math.PI / 2, false);    
            //按照指定的路径绘制弧线
            ctx.stroke();
        }
    };

</script>

<div id="div01">
    <canvas id="myCanvas" width="800px" height="600px" style="border: 1px solid red;">
        您的浏览器不支持canvas标签。
    </canvas>
</div>

</html>

 

 

2、

 

WaterDrop

原文:http://www.cnblogs.com/h5skill/p/5277637.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!