canvas连线
来源:互联网 发布:翼年代记。淘宝 编辑:程序博客网 时间:2024/04/27 15:29
.bj{width: 100%;height: 100%;background-color: red;position: relative;z-index: 1;}
#canvas{position: absolute;z-index: 2;}
</style>
<div class="bj">
<canvas id="myCanvas" width="200" height="200" >
</canvas>
</div>
<script type="text/javascript">
var canvas = document.getElementById("myCanvas");
//var zhezhao = document.getElementById("zhezhao");
var pmk = $(document).width();
var pmg = $(document).height();
$('#myCanvas').attr("width",pmk);
$('#myCanvas').attr("height",pmg);
var cxt = canvas.getContext("2d");
cxt.fillStyle = "#000";
cxt.fillRect(0,0,pmk,pmg);
cxt.strokeStyle = "ff0000";
//cxt.strokeStyle = "rgba(255,0,0,0.5)";//线的颜色
cxt.lineWidth = 20;//线的宽度
cxt.lineCap = "round";//线的两头样式为圆
cxt.lineJoin = "round";//线的拐角样式为圆
// cxt.beginPath();
// cxt.moveTo(100,100);
// cxt.lineTo(200,200);
// cxt.lineTo(100,200);
// cxt.stroke();
cxt.save();
var startX,startY;
function touchStart(event){
event.preventDefault();
if(!event.touches.length) return;
var touch = event.touches[0];
startX = touch.pageX;
startY = touch.pageY;
cxt.arc(startX,startY,10,0,Math.PI*2,true);
cxt.stroke();
//cxt.moveTo(100,100);
//alert(startX);
// cxt.beginPath();
// cxt.clearRect(startX,startY,50,50);
// cxt.closePath();
// cxt.fill();
// cxt.restore();
}
//add touch start listener
canvas.addEventListener("touchstart",touchStart,false);
</script>
- canvas连线
- canvas连线
- canvas连线
- canvas动态的连线
- canvas 雪花连线
- Canvas线段终点和连线
- canvas实现粒子星空连线
- android下canvas连线题思路
- Android 画布Canvas之控件连线操作
- 连线游戏
- 硬连线
- 连线心得
- 电话连线
- 连线错误
- JsPlump连线
- Activiti连线
- 解开连线
- Canvas
- Xcode5.1.1 模拟器报Cannot find executable for CFBundle 0xd38e940 解决方法
- 中国省市县乡村五级数据库
- element not visible的解决方法
- 搭建IIS提示:Logon failure: user account restriction
- 文件存储与误删除恢复的几点建议
- canvas连线
- 数字图象处理图片库
- 港股创下6年新高后蕴藏三大风险?
- struts2 Action 总结
- img标签中alt与titile的区别
- 深入剖析位运算
- Unbuntu12.04下GAMIT10.40安装说明
- 豆机,即梅花瓶或高尔顿瓶的Java实现
- awk 查看ip连接数(常见应用一)