html5做圆角

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3.   <head>  
  4.     <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
  5.     <meta http-equiv="Content-Language" content="zh-cn" />  
  6.     <title>画一个圆角图</title>  
  7.     <script type="text/javascript" src="jquery-1.4.min.js"></script>  
  8.     <script type="text/javascript"><!--   
  9.        
  10.     $(function(){   
  11.         var elem = $("#myCanvas")[0];   
  12.         if (!elem || !elem.getContext) {   
  13.             return;   
  14.         }   
  15.   
  16.         //CanvasRenderingContext2D   
  17.         var ctx = elem.getContext('2d');   
  18.         ctx.fillStyle   = '#00f';   
  19.         ctx.strokeStyle = '#0f0';   
  20.         ctx.lineWidth   = 10;   
  21.         ctx.globalAlpha   = 1;   
  22.         //lineCap指定线条的末端如何绘制,round这个值指定了线段应该带有一个半圆形的线帽,半圆的直径等于线段的宽度,并且线段在端点之外扩展了线段宽度的一半。   
  23.         ctx.lineCap = "round";   
  24.         //lineJoin 属性说明如何绘制交点。值 "round" 说明定点的外边缘应该和一个填充的弧接合,这个弧的直径等于线段的宽度。"   
  25.         ctx.lineJoin = "round";   
  26.   
  27.         ctx.beginPath();   
  28.         ctx.moveTo(10, 10);   
  29.         ctx.lineTo(200, 10);   
  30.         ctx.lineTo(200, 200);   
  31.         ctx.lineTo(10, 200);   
  32.         ctx.lineTo(10, 10);   
  33.         //ctx.fill();   
  34.         ctx.stroke();   
  35.         ctx.closePath();   
  36.     });   
  37.     // --></script>  
  38.   </head>  
  39.   <body>  
  40.     <canvas id="myCanvas" width="300" height="300">您的浏览器不支持HTML5元素</canvas>  
  41.   </body>  
  42. </html>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值