h5-9 canvas
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
body{ background:black;}
#c1{ background:white;}
</style>
<script>
window.onload = function(){
var oC = document.getElementById('c1');
var oGC = oC.getContext('2d'); oGC.fillRect(0,0,100,100); oGC.fillStyle = 'red';
oGC.globalAlpha = 0.5; oGC.fillRect(50,50,100,100); };
</script>
</head> <body>
<canvas id="c1" width="400" height="400"></canvas>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
body{ background:black;}
#c1{ background:white;}
</style>
<script>
window.onload = function(){
var oC = document.getElementById('c1');
var oGC = oC.getContext('2d'); oGC.fillRect(0,0,100,100); oGC.fillStyle = 'red'; oGC.globalCompositeOperation = 'xor'; oGC.fillRect(50,50,100,100); };
</script>
</head> <body>
<canvas id="c1" width="400" height="400"></canvas>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
body{ background:black;}
#c1{ background:white;}
#img1{ background:white;}
</style>
<script>
window.onload = function(){
var oImg = document.getElementById('img1');
var oC = document.getElementById('c1');
var oGC = oC.getContext('2d'); oGC.fillRect(0,0,100,100); oGC.fillStyle = 'red'; oGC.globalCompositeOperation = 'xor'; oGC.fillRect(50,50,100,100); //alert( oC.toDataURL() ); oImg.src = oC.toDataURL();
};
</script>
</head> <body>
<canvas id="c1" width="400" height="400"></canvas>
<img id="img1" src="" />
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
body{ background:black;}
#c1{ background:white;}
#img1{ background:white;}
</style>
<script>
window.onload = function(){
var oImg = document.getElementById('img1');
var oC = document.getElementById('c1');
var oGC = oC.getContext('2d'); oGC.beginPath();
oGC.arc(100,100,50,0,360*Math.PI/180,false);
oGC.closePath();
oGC.fill(); oC.onmousedown = function(ev){
var ev = ev || window.event;
var x = ev.clientX - oC.offsetLeft;
var y = ev.clientY - oC.offsetTop; if( oGC.isPointInPath(x,y) ){
alert(123);
}
}; };
</script>
</head> <body>
<canvas id="c1" width="400" height="400"></canvas>
<img id="img1" src="" />
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
body{ background:black;}
#c1{ background:white;}
#img1{ background:white;}
</style>
<script>
window.onload = function(){
var oImg = document.getElementById('img1');
var oC = document.getElementById('c1');
var oGC = oC.getContext('2d'); oGC.beginPath();
oGC.arc(100,100,50,0,360*Math.PI/180,false);
oGC.closePath();
oGC.fill(); oGC.beginPath();
oGC.arc(200,200,50,0,360*Math.PI/180,false);
oGC.closePath();
oGC.fill(); oC.onmousedown = function(ev){
var ev = ev || window.event;
var x = ev.clientX - oC.offsetLeft;
var y = ev.clientY - oC.offsetTop; if( oGC.isPointInPath(x,y) ){//isPointInPath只作用于最后画出来的oGC
alert(123);
}
}; };
</script>
</head> <body>
<canvas id="c1" width="400" height="400"></canvas>
<img id="img1" src="" />
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
body{ background:black;}
#c1{ background:white;}
#img1{ background:white;}
</style>
<script>
window.onload = function(){
var oImg = document.getElementById('img1');
var oC = document.getElementById('c1');
var oGC = oC.getContext('2d'); var c1 = new Shape(100,100,50);
var c2 = new Shape(200,200,50); oC.onmousedown = function(ev){
var ev = ev || window.event;
var point = {
x : ev.clientX - oC.offsetLeft,
y : ev.clientY - oC.offsetTop
};
c1.reDraw(point);
c2.reDraw(point);
}; c1.click = function(){
alert(123);
}; c2.click = function(){
alert(456);
}; function Shape(x,y,r){//构造函数
this.x = x;
this.y = y;
this.r = r;
oGC.beginPath();
oGC.arc(this.x,this.y,this.r,0,360*Math.PI/180,false);
oGC.closePath();
oGC.fill();
}
Shape.prototype.reDraw = function(point){//构造函数添加方法
oGC.beginPath();
oGC.arc(this.x,this.y,this.r,0,360*Math.PI/180,false);
oGC.closePath();
oGC.fill();
if( oGC.isPointInPath(point.x,point.y) ){
this.click();
}
};
};
</script>
</head> <body>
<canvas id="c1" width="400" height="400"></canvas>
<img id="img1" src="" />
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
body{ background:black;}
#c1{ background:white;}
</style>
<script type="text/javascript" src="jCanvaScript.1.5.18.min.js"></script> //画布的js
<script>
window.onload = function(){ var oC = document.getElementById('c1');
var oGC = oC.getContext('2d'); jc.start('c1',true); //开始,第二个参数:代表重绘的意思,只有重绘了才有点击事件。 //jc.rect(100,100,50,50,'#ff0000',1);//画矩形
jc.circle(100,100,50,'#ff0000',1).click(function(){//画园,1表示填充,0表示不填充。
alert(123);
}); jc.start('c1');//闭合 };
</script>
</head> <body>
<canvas id="c1" width="400" height="400"></canvas>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
body{ background:black;}
#c1{ background:white;}
</style>
<script type="text/javascript" src="jCanvaScript.1.5.18.min.js"></script>
<script>
window.onload = function(){ var oC = document.getElementById('c1');
var oGC = oC.getContext('2d'); jc.start('c1',true); //第二个参数:代表重绘的意思 //jc.rect(100,100,50,50,'#ff0000',1);
jc.circle(100,100,50,'#ff0000',1).draggable();//拖拽了就可以拖着走了 jc.start('c1'); };
</script>
</head> <body>
<canvas id="c1" width="400" height="400"></canvas>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
body{ background:black;}
#c1{ background:white;}
</style>
<script type="text/javascript" src="jCanvaScript.1.5.18.min.js"></script>
<script>
window.onload = function(){
var oInput = document.getElementById('input1');
var oC = document.getElementById('c1');
var oGC = oC.getContext('2d'); jc.start('c1',true); //第二个参数:代表重绘的意思 //jc.rect(100,100,50,50,'#ff0000',1);
jc.circle(100,100,50,'#ff0000',1).id('c11');//给js加id为c11 jc.start('c1');//关闭,相当于close. oInput.onclick = function(){ jc('#c11').color('#ffff00');//通过#c11确定上面的js }; };
</script>
</head> <body>
<canvas id="c1" width="400" height="400"></canvas>
<input type="button" value="点击" id="input1" />
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
body{ background:black;}
#c1{ background:white;}
</style>
<script type="text/javascript" src="jCanvaScript.1.5.18.min.js"></script>
<script>
window.onload = function(){
var oInput = document.getElementById('input1');
var oC = document.getElementById('c1');
var oGC = oC.getContext('2d'); jc.start('c1',true); //第二个参数:代表重绘的意思 //jc.rect(100,100,50,50,'#ff0000',1);
jc.circle(100,100,50,'#ff0000',1).id('c1'); jc.start('c1'); oInput.onclick = function(){ jc('#c1').color('#ffff00').animate({x:200,y:200,radius:5},2000);//{x:200,y:200,radius:5}是一个json,radius表示半径变成5, }; };
</script>
</head> <body>
<canvas id="c1" width="400" height="400"></canvas>
<input type="button" value="点击" id="input1" />
</body>
</html>
h5-9 canvas的更多相关文章
- h5标签canvas关于getImageData跨域的问题
h5标签canvas关于getImageData跨域的问题 在学习h5的时候,canvas标签中getImageData()报错:security error! 具体代码如下(chrome浏览器): ...
- 关于h5绘制canvas生成图片的注意点!
1.第一个是关于移动端自适应的问题: 答:如果是最后只要一张canvas生成的图片,而不是要绘制的canvas的图形,则不需要考虑自适应,绘制canvas的时候的宽高,可以直接写成UI提供的图的大小, ...
- 关于H5的Canvas
1.什么是canvas? <canvas>标签是h5新增的,通过脚本(通常是js)来绘制图形,canvas只是一个图形容器,或者说是画布. canvas可以绘制路径.图形.字以及添加图像. ...
- HTML5 Canvas绘图基本使用方法, H5使用Canvas绘图
Canvas 是H5的一部分,允许脚本语言动态渲染图像.Canvas 定义一个区域,可以由html属性定义该区域的宽高,javascript代码可以访问该区域,通过一整套完整的绘图功能(API),在网 ...
- H5使用Canvas绘图
一.什么是Canvas Canvas 是H5的一部分,允许脚本语言动态渲染图像.Canvas 定义一个区域,可以由html属性定义该区域的宽高,javascript代码可以访问该区域,通过一整套完整的 ...
- 用H5的canvas做时钟
<!doctype html><html> <head> <meta charset="UTF-8"> <title>D ...
- H5 认识canvas
不同于SVG,HTML中的元素canvas只支持一种原生的图形绘制:矩形.所有其他的图形的绘制都至少需要生成一条路径.不过,我们拥有众多路径生成的方法让复杂图形的绘制成为了可能. canvas提供了三 ...
- H5标签-canvas实现颜色拾取功能
HTML5 <canvas> 标签是用于绘制图像,不过,<canvas> 元素本身并没有绘制能力(它仅仅是图形的容器),必须使用脚本(通常是 JS)来完成实际的绘图任务. &l ...
- H5之canvas简单入门
<canvas></canvas>是html5出现的新标签,像所有的dom对象一样它有自己本身的属性.方法和事件,其中就有绘图的方法,js能够调用它来进行绘图 <canv ...
- H5的canvas绘图技术
canvas元素是HTML5中新添加的一个元素,该元素是HTML5中的一个亮点.Canvas元素就像一块画布,通过该元素自带的API结合JavaScript代码可以绘制各种图形和图像以及动画效果. 1 ...
随机推荐
- Spring Boot (9) mybatis全注解化
ORM对比图 框架对比 Spring JDBC Spring Data Jpa Mybatis 性能 性能最好 性能最差 居中 代码量 多 少 多 学习成本 低 高 居中 推荐指数 ❤❤❤ ❤❤❤❤❤ ...
- [转]深入javascript——构造函数和原型对象
对象,是javascript中非常重要的一个梗,是否能透彻的理解它直接关系到你对整个javascript体系的基础理解,说白了,javascript就是一群对象在搅..(哔!). 常用的几种对象创建模 ...
- Android 存储路径选择
Android能用来存储的地方有两个,一个是手机内置的存储空间,一个是外置的SD卡,内置的存储空间一般比较小,所以应用的缓存建议存储在外置的SD卡中. 在Android系统中如何获得存储的路径呢? p ...
- R 连接mysql数据库
一.配置RODBC 1.R下载RODBC包,安装好.2.在http://dev.mysql.com/downloads/connector/odbc下载mySQL ODBC,安装好.3.windows ...
- OpenCV:OpenCV目标检测Boost方法训练
在古老的CNN方法出现以后,并不能适用于图像中目标检测.20世纪60年代,Hubel和Wiesel( 百度百科 )在研究猫脑皮层中用于局部敏感和方向选择的神经元时发现其独特的网络结构可以有效地降低反馈 ...
- ANN:DNN结构演进History—LSTM网络
为了保持文章系列的连贯性,参考这个文章: DNN结构演进History-LSTM_NN 对于LSTM的使用:谷歌语音转录背后的神经网络 摘要: LSTM使用一个控制门控制参数是否进行梯度计算,以此避免 ...
- structure vs class in swift language
Both class and structure can do: Define properties to store values Define methods to provide functio ...
- C# 带Cookies发送请求
#region --来自黄聪 void F1() { #region --创建cookies容器 添加Cookies和对应的URl(Hots主) CookieContainer cc = new Co ...
- html 表单赋值 和 时间戳 转换
<script> window.onload = function () { var str; // console.log(@ViewBag.ID); $.post("/Ser ...
- 构造函数+原型的js混合模式
function Parent(){ this.name = "李小龙"; this.age = "30"; };Parent.prototype.lev=fu ...