3.3.6_在圆弧周围绘制文本
来源:互联网 发布:北师大网络教育会计学 编辑:程序博客网 时间:2024/05/16 17:55
3.3.6_在圆弧周围绘制文本
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>在圆弧周围绘制文本</title> <style> body{ background: #eee; } #canvas{ background: #fff; cursor: pointer; margin-left: 10px; margin-top: 10px; box-shadow: 4px 4px 8px rgba(0,0,0,0.5); -webkit-box-shadow: 4px 4px 8px rgba(0,0,0,0.5); -moz-box-shadow: 4px 4px 8px rgba(0,0,0,0.5); } </style> </head> <body> <canvas id="canvas" width="1000" height="600"></canvas> </body> <script> var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); //文本样式设置 var text_fill_style = 'rgba(100,130,240,0.5)'; var text_stroke_style = 'rgba(200,0,0,0.7)'; var text_size = 64; //圆弧设置 circle = { x:canvas.width/2, y:canvas.height/2, radius:200 }; //初始化 context.textAlign = 'center'; context.textBaseline = 'middle'; //绘制圆弧形文字 drawCircularText('clockwise around the circle',Math.PI*2,Math.PI/8); function drawCircularText(string,startAngle,endAngle){ var radius = circle.radius; var angleDecrement = (startAngle-endAngle)/(string.length-1); //每个字符间隔的角度 var angle = parseFloat(startAngle); var index = 0; //第个字符的标记 var character; context.save(); context.fillStyle = text_fill_style; context.strokeStyle = text_stroke_style; context.font = text_size + 'px lucida sans'; while(index<string.length){ character = string.charAt(index); context.save(); context.beginPath(); context.translate(circle.x+Math.cos(angle)*radius,circle.y - Math.sin(angle)*radius); context.rotate(Math.PI/2-angle); context.fillText(character,0,0); context.strokeText(character,0,0); angle -= angleDecrement; index++; context.restore(); } context.restore(); } </script></html>
0 0
- 3.3.6_在圆弧周围绘制文本
- canvas绘制文本 圆弧 详解
- Html5 Canvas 系列_绘图三(H5 绘制圆弧)
- CSSDIV:让文本字符环绕在你的图片周围
- 3.3.4_绘制坐标系旁边的文本标签
- j2me-绘制圆弧
- CANVAS绘制圆弧
- drawArc绘制圆弧
- drawArc方法:绘制圆弧
- Java绘图: 使用Graphics类绘制线段、矩形、椭圆/圆弧/扇形、图片、文本
- Java绘图: 使用Graphics类绘制线段、矩形、椭圆/圆弧/扇形、图片、文本
- 在指定区域内绘制文本
- 从绘制圆弧思考定位
- OpenGL绘制圆弧/圆/饼图
- svg绘制圆弧(一)
- svg绘制圆弧(二)
- 3.canvas:圆弧的绘制
- [Cocoa]_[初级]_[如何绘制带颜色的文本]
- dtb to dts by dtc
- 服务器端渲染和客户端渲染有什么区别?
- 第八届山东省ACM省赛比赛感想
- 服务机器人常用的定位导航技术及优缺点分析
- JS 的引用赋值与传值赋值
- 3.3.6_在圆弧周围绘制文本
- 解决cron无法运行报错:FAILED to authorize user with PAM (Module is unknown)
- Java 动态代理与class字节码动态修改技术
- Longest Substring Without Repeating Characters
- 【翻译】【Redis笔记】How to start using RDM
- web开发-MyEclipse下配置和创建web&java工程过程-学习笔记十五
- 3.4.1_指示文本输入位置的光标
- CS231n系列课程Lecture 7: Convolutional Neural Networks
- 【脚本语言系列】关于PythonGUI界面PyQT,你需要知道的事