我尝试在draw()函数中使用此代码在处理过程中创建的图形程序上写入竖排文本。
// Translate to where I want text to be.
translate(20., 30.);
// Center align text
textAlign(CENTER);
// Rotate text-to-be written by 270 degrees to make it vertical.
rotate(270.);
// Write vertical text.
text("Some Vertical Text", 0, 0);
// Undo rotation and translation.
rotate(-270.);
translate(-20., -30.);但是,此代码不会垂直旋转文本。事实上,书写的文本既不是垂直的,也不是水平的。
怎么一回事?
发布于 2012-02-27 08:37:31
必须以弧度为单位指定角度。请尝试使用rotate(PI/2.0*3)。如果您不喜欢使用弧度,可以使用radians(x)函数进行转换。最终结果看起来像这样:rotate(radians(270))。
哦,一般来说,使用pushMatrix()保存当前的平移/旋转/状态,然后使用popMatrix恢复它,而不是旋转回来,这是一个更好的想法。旋转通常会给你带来很小的舍入误差,这些误差会很快累积起来。
https://stackoverflow.com/questions/9458705
复制相似问题