1 2 3 4 5 6 7 8 9 10 | <canvas> <view bgcolor="#ff0000" width="20" height="$once{width}" x="${radius + (radius * Math.cos(animCnt))}" y="${radius + (radius * Math.sin(animCnt))}"> <attribute name="animCnt"/> <attribute name="radius" value="30"/> <animator attribute="animCnt" from="0" to="$once{Math.PI * -2}" duration="1000" motion="linear" repeat="Infinity"/> </view> </canvas> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | <canvas width="115" height="95"> <drawview width="200" height="200" x="5" y="5"> <method event="oninit"> // Draw a black square this.strokeStyle = 0x000000; this.moveTo(0, 0); this.lineTo(25, 0); this.lineTo(25, 25); this.lineTo(0, 25); this.closePath(); this.stroke(); // Reset the path and draw a square with red fill // and a black outline this.beginPath(); this.fillStyle = 0xff0000; this.moveTo(40, 0); this.lineTo(65, 0); this.lineTo(65, 25); this.lineTo(40, 25); this.closePath(); this.fill(); // Draw a square with a square filled with a gradient // from white to gray this.beginPath(); // Create the gradient, adding color 'stops' (where // the color shifts) var gradient = this.createLinearGradient(80, 0, 105, 25); gradient.addColorStop(0, 0xffffff); gradient.addColorStop(1, 0x000000); this.fillStyle = gradient; this.moveTo(80, 0); this.lineTo(105, 0); this.lineTo(105, 25); this.lineTo(80, 25); this.closePath(); this.fill(); this.stroke(); </method> </drawview> </canvas> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |