jtopo
2015-06-19 10:49
218 查看
jtopo文本换行
扩展prototype属性:
节点调用:
欢迎转载,请注明出处。
扩展prototype属性:
CanvasRenderingContext2D.prototype.wrapText = function(str,x,y){ var index = str.indexOf('-'); str2= str.substr(index+1,str.length); str1= str.substr(0,index); var textArray = new Array(str1,str2); if(textArray==undefined||textArray==null)return false; var rowCnt = textArray.length; var i = 0,imax = rowCnt,maxLength = 0;maxText = textArray[0]; for(;i<imax;i++){ var nowText = textArray[i],textLength = nowText.length; if(textLength >=maxLength){ maxLength = textLength; maxText = nowText; } } var maxWidth = this.measureText(maxText).width; var lineHeight = this.measureText("元").width; x-= lineHeight*2; for(var j= 0;j<textArray.length;j++){ var words = textArray[j]; this.fillText(words,x,y); y+= lineHeight; } };
节点调用:
node.paintText = function(a){ a.beginPath(), a.font = this.font, a.wrapText(this.text,this.height/2,this.height); a.closePath() }
欢迎转载,请注明出处。
相关文章推荐
- linux发送邮件和附件---mail,mailx
- linux下用vim编写C/C++单个源程序的基本方法
- Apache负载均衡请求至Tomcat及DeltaManager的使用
- 细细品味Ubuntu Scope中的category renderer模版
- 密码找回漏洞总结
- usr/bin/ld: cannot find 错误解决方法
- php-fpm开机自动启动Shell脚本
- 使用export/import导出和导入docker容器
- 整理的Linux Shell语法速查表(用C语言语法来作对比)
- 利用Nginx做负载均衡
- linux上的语音识别程序
- linux下eclipse交叉开发环境搭建
- Nginx APP接口连接超时
- centos安装flashplayer
- Linux入门问题解决——2015.06.19
- linux alarm函数
- 在Linux里设置环境变量的方法(export PATH)
- git 忽略某些文件
- Mysql 5.6 双主互备高可用(Keepalived+mysql) (二)
- linux编程