HTML5画布沿弧路径文本
来源:互联网 发布:js取绝对值函数 编辑:程序博客网 时间:2024/05/22 07:56
<!DOCTYPE HTML><html> <head> <style> body { margin: 0px; padding: 0px; } </style> </head> <body> <canvas id="myCanvas" width="578" height="250"></canvas> <script> function drawTextAlongArc(context, str, centerX, centerY, radius, angle) { var len = str.length, s; context.save(); context.translate(centerX, centerY); context.rotate(-1 * angle / 2); context.rotate(-1 * (angle / len) / 2); for(var n = 0; n < len; n++) { context.rotate(angle / len); context.save(); context.translate(0, -1 * radius); s = str[n]; context.fillText(s, 0, 0); context.restore(); } context.restore(); } var canvas = document.getElementById('myCanvas'), context = canvas.getContext('2d'), centerX = canvas.width / 2, centerY = canvas.height - 30, angle = Math.PI * 0.8, radius = 150; context.font = '30pt Calibri'; context.textAlign = 'center'; context.fillStyle = 'blue'; context.strokeStyle = 'blue'; context.lineWidth = 4; drawTextAlongArc(context, 'Text along arc path', centerX, centerY, radius, angle); // draw circle underneath text context.arc(centerX, centerY, radius - 10, 0, 2 * Math.PI, false); context.stroke(); </script> </body></html>
0 0
- HTML5画布沿弧路径文本
- HTML5画布文本教程
- HTML5画布路径教程
- HTML5画布文本包装教程
- HTML5画布文本基线教程
- HTML5画布文本颜色教程
- HTML5画布文本中风教程
- HTML5画布文本标准教程
- HTML5画布弧教程
- HTML5画布kineticjs路径文字教程
- html5画布
- HTML5画布
- HTML5 画布
- html5画布
- HTML5画布
- HTML5画布文本字体、大小和风格的教程
- HTML5特性 > Canvas >画布
- HTML5画布画图实例
- 合并果子
- "等差三元组"
- Excle学习
- 合唱队形
- iOS 健值编码(KVC)与反射机制的研究
- HTML5画布沿弧路径文本
- 原谅我
- Credential Provider
- HTML5画布行星图像映射
- 64位win7下vc2010如何调用matlab2012a中生成的dll文件
- iOS 中由谓词引发的正则血案正在破案中
- 不高兴的津津
- trylock的返回值
- Python自动化测试 (一) Eclipse+Pydev 搭建开发环境