便条首页
搜索:
全文搜
搜标签
关注的
显 示
搜索标签
登陆后可以记录私有便条!
8606
图片
admin
分数: 0 (0 次)
创建: 2015-08-09 15:19:25
更新: 2021-02-14 13:54:43
绘图 测试 组件
//时钟 version 0.2 function Shape_$ID(options) { this.brushTypeOnly = 'stroke'; Base.call(this, options); } Shape_$ID.prototype = { type : 'auid', redraw_time_count: 0, redraw_time: 1, buildPath : function(ctx, style) { //获取当前时间 var now=new Date(); var hour=now.getHours(); var minute=now.getMinutes(); var second=now.getSeconds(); var x = style.x; var y = style.y; var r = 50; //ctx.rect(x-85,y-85,170,170); ctx.clearRect(x-85,y-85,170,170); ctx.strokeStyle = 'rgba(255, 0, 0, 0.5)';//红色 ctx.lineWidth=8; ctx.arc(x, y, 1.5*r, 0, Math.PI * 2, true); ctx.stroke(); ctx.beginPath(); ctx.lineWidth=3; ctx.strokeStyle = 'rgba(0, 0, 0, 0.9)';//black var a=0; for (var i=0;i<12;i++) { a=Math.PI/6.0*i; ctx.moveTo(x+1.1*r*Math.sin(a),y-1.1*r*Math.cos(a)); ctx.lineTo(x+1.3*r*Math.sin(a),y-1.3*r*Math.cos(a)); } ctx.stroke(); ctx.beginPath(); ctx.strokeStyle = 'rgba(0, 0, 255, 0.9)';//blue ctx.lineWidth=2; a=Math.PI/6.0*(hour+minute/60); ctx.moveTo(x, y); ctx.lineTo(x+0.5*r*Math.sin(a),y-0.5*r*Math.cos(a)); a=Math.PI/30*minute; ctx.moveTo(x, y); ctx.lineTo(x+0.7*r*Math.sin(a),y-0.7*r*Math.cos(a)); ctx.stroke(); ctx.beginPath(); //重新绘制一条全新的路径了,之前画的东西无关 a=Math.PI/30*second; ctx.moveTo(x, y); ctx.lineTo(x+0.8*r*Math.sin(a),y-0.8*r*Math.cos(a)); ctx.strokeStyle = 'rgba(255, 0, 0, 0.9)';//红色 ctx.stroke(); return; }, /** * 返回矩形区域,用于局部刷新和文字定位 * @param {Object} style */ getRect : function(style) { return { x : style.x-65, y : style.y-65, width : 130, height : 130 }; }, isCover : function(x, y) { var originPos = this.getTansform(x, y); x = originPos[0]; y = originPos[1]; if (x >= (this.style.x - 65) && x <= (this.style.x + 130) && y >= this.style.y - 65 && y <= (this.style.y + 130) ) { return true; } return false; } } require('zrender/tool/util').inherits(Shape_$ID, Base);