<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<canvas id="canvas" style="margin:0 auto;">
The current browser does not support Canvas, can replace the browser a try!
</canvas> <script> // 绘制矩形
function drawRect(ctx,x,y,width,height,borderWidth,borderColor,fillColor){
ctx.beginPath();
ctx.moveTo(x,y);
ctx.lineTo(x+width,y);
ctx.lineTo(x+width,y+height);
ctx.lineTo(x,y+height);
ctx.closePath(); ctx.lineWidth = borderWidth;
ctx.strokeStyle = borderColor;
ctx.fillStyle = fillColor; ctx.fill();
ctx.stroke();
} window.onload = function(){
var canvas = document.getElementById('canvas'); canvas.width = 1024;
canvas.height = 768; if(canvas.getContext('2d')){
var context = canvas.getContext('2d'); drawRect(context,100,100,400,400,10,"blue","yellow") }else{
alert('当前游览器不支持Canvas,请更换游览器后再试!');
}
}
</script>
</body>
</html>

最新文章

  1. php 单双引号的区别
  2. SQLServer字符操作
  3. 实验验证redis的快照和AOF
  4. 认识Runtime1
  5. struts2验证框架1
  6. [原创] 在spring 中使用quarts
  7. *ecsho 的商品详细页面上获取该商品的一级分类ID及NAME
  8. Angularjs Controller 间通信机制
  9. 【贪心+一点小思路】Zoj - 3829 Known Notation
  10. 编辑器笔记——sublime text3 编译sass
  11. 数据库 一致性读&amp;&amp;当前读
  12. mybatis()
  13. JQ模仿select
  14. java socket线程通信
  15. hdu1541 Stars 树状数组
  16. node.js之setTimeout()、clearTimeout()与 setInterval()与clearInterval()
  17. 【Ubuntu 16】 SSH免密码登录
  18. Disconnected from the target VM, address: &#39;127.0.0.1:57178&#39;, transport: &#39;socket&#39;
  19. mysql format函数对数字类型转化的坑
  20. HDU 4918 Query on the subtree(动态点分治+树状数组)

热门文章

  1. js- DOM事件之按钮绑定函数注意事项
  2. 利用蒙特卡洛(Monte Carlo)方法计算π值[ 转载]
  3. 数据库路由中间件MyCat - 源代码篇(7)
  4. spring boot开发笔记——mybatis
  5. Flask 中的 5种返回值
  6. 2018CCPC-女生专场
  7. ORACLE 日期加减操作
  8. 分布式控制系统Git学习
  9. LeetCode--No.014 Longest Common Prefix
  10. Django项目中使用celery做异步任务