textWidth()
例子
textSize(28);
char c = ‘T’;
float cw = textWidth(c);
text(c, 0, 40);
line(cw, 0, cw, 50);
String s = “Tokyo”;
float sw = textWidth(s);
text(s, 0, 85);
line(sw, 50, sw, 100);
描述
计算并返回任何一个字母或者字符串文本的宽度
语法
textWidth(c)
textWidth(str)
参数
c 字符:要测量的字符
str 字符串:要测量的字符串
返回值类型
Float
相关
loadFont()
text()
textFont()
textSize()
- 本文固定链接: http://iprocessing.cn/2017/07/15/textwidth文本宽度/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表