Processing, text()用法介绍。
用法
text(c, x, y)text(c, x, y, z)text(str, x, y)text(chars, start, stop, x, y)text(str, x, y, z)text(chars, start, stop, x, y, z)text(str, x1, y1, x2, y2)text(num, x, y)text(num, x, y, z)
参数
c(char)要显示的字母数字字符x(float)文本的 x 坐标y(float)文本的 y 坐标z(float)文本的 z 坐标chars(char[])要显示的字母数字符号start(int)开始写入字符的数组索引stop(int)停止写入字符的数组索引x1(float)默认情况下,文本的 x 坐标,请参阅rectMode() 了解更多信息y1(float)默认情况下,文本的 y 坐标,有关详细信息,请参阅rectMode()x2(float)默认情况下,文本框的宽度,请参阅rectMode() 了解更多信息y2(float)默认情况下,文本框的高度,请参阅rectMode() 了解更多信息num(float, int)要显示的数值
返回
void
说明
将文本绘制到屏幕上。在屏幕上附加参数指定的位置显示第一个参数中指定的信息。除非使用 textFont() 函数设置字体,否则将使用默认字体,除非使用 textSize() 设置字体,否则将使用默认大小。使用fill() 函数更改文本的颜色。文本显示与textAlign() 函数相关,该函数提供了在坐标的左侧、右侧和中心绘制的选项。
x2 和y2 参数定义要在其中显示的矩形区域,并且只能与字符串数据一起使用。指定这些参数时,它们将根据当前的rectMode() 设置进行解释。不完全适合指定矩形的文本将不会被绘制到屏幕上。
请注意,Processing 现在允许您调用 text() 而无需先使用 textFont() 指定 PFont。在这种情况下,将使用通用的sans-serif 字体。 (见上面的第三个例子。)
例子
size(400, 400);
textSize(128);
text("word", 40, 120);
fill(0, 408, 612);
text("word", 40, 240);
fill(0, 408, 612, 204);
text("word", 40, 360);
size(400, 400, P3D);
textSize(128);
fill(0, 408, 612, 816);
text("word", 48, 180, -120); // Specify a z-axis value
text("word", 48, 240); // Default depth, no z-value specified
size(400, 400);
String s = "The quick brown fox jumps over the lazy dog.";
fill(200);
text(s, 40, 40, 280, 320); // Text wraps within text box
相关用法
- Processing texture()用法及代码示例
- Processing textSize()用法及代码示例
- Processing textureMode()用法及代码示例
- Processing textLeading()用法及代码示例
- Processing textDescent()用法及代码示例
- Processing textFont()用法及代码示例
- Processing textAscent()用法及代码示例
- Processing textAlign()用法及代码示例
- Processing textMode()用法及代码示例
- Processing textWidth()用法及代码示例
- Processing textureWrap()用法及代码示例
- Processing thread()用法及代码示例
- Processing triangle()用法及代码示例
- Processing trim()用法及代码示例
- Processing true用法及代码示例
- Processing this用法及代码示例
- Processing try用法及代码示例
- Processing tint()用法及代码示例
- Processing tan()用法及代码示例
- Processing translate()用法及代码示例
- Processing FFT用法及代码示例
- Processing SawOsc.pan()用法及代码示例
- Processing FloatDict用法及代码示例
- Processing FFT.stop()用法及代码示例
- Processing join()用法及代码示例
注:本文由纯净天空筛选整理自processing.org大神的英文原创作品 text()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
