首页 技术 正文
技术 2022年11月11日
0 收藏 796 点赞 3,810 浏览 704 个字
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<h3>什么是canvas?</h3>
<p>canvas是在html5中的一个重要元素,专门用来绘制图形。</p>
<h4>画布的创建方法:指定id、width、height</h4>
<h4>取得上下文:getContext("2d")</h4>
<h4>绘制图形的方法:fillstyle填充、storkestyle边框</h4>
<canvas id="canvas" width="500" height="350"></canvas>
<script>
var canvas_id = document.getElementById('canvas');
var content = canvas_id.getContext('2d');
content.fillStyle = "#000"; //背景颜色 设置或返回用于填充绘画的颜色、渐变或模式
content.strokeStyle = "#f60"; //边框颜色 设置或返回用于笔触的颜色、渐变或模式
content.lineWidth = 5; //边框宽度 设置或返回当前的线条宽度
content.fillRect(0,0,500,350); //最外层 绘制“被填充”的矩形
content.strokeRect(50,50,100,200);//里层 绘制矩形(无填充)
content.strokeRect(100,100,100,200);//里层 绘制矩形(无填充) </script>
</body>
</html>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,489
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,904
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,490
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,291