java - 改进旋转文本的显示

标签 java text rotation processing

我有以下代码,改编自在线旋转文本示例。该代码工作正常,因为它将文本旋转到正确的角度,但我想知道是否有办法提高旋转文本的准确性和清晰度。在我的显示器上,旋转的文本看起来像是“阶梯状”而不是平滑的。

PFont f;
String message = "abcdefghijklmnopqrstuvwxyz";
float theta, x;

void setup() {
  size(800, 200);
  f = createFont("Arial",20,true);
}

void draw() { 
 // background(255);
  fill(0);
  textFont(f);    // Set the font
  translate(x,height/2);  // Translate to the center
  rotate(theta);                // Rotate by theta
  textAlign(LEFT);            
  text(message,0,0);            
  theta += 0.1;                // Increase rotation
  x += textWidth(message);
  if (x>800){noLoop(); }
}

我已经通过示例进行了修改以帮助显示差异。在新代码中,我将文本更改为一串下划线,并用红色绘制了一条引用线。如果它在您的机器上运行相同,您应该会在由下划线创建的黑线中看到一条惊人的线。

String message = "________";
float theta, x;
PFont f;

void setup() {
  size(800, 200);
  f = loadFont("ArialMT-20.vlw");
  smooth();
}

void draw() { 
  fill(0);
  textFont(f);    // Set the font

  translate(x,height/2);  // Translate to the center
  rotate(theta);                // Rotate by theta

  text(message,0,0);

  stroke(255,0,0);
  strokeWeight(2);
  line(0,0,textWidth(message),0);

  theta += 0.1;                // Increase rotation
  x += textWidth(message);
  if (x>800){noLoop(); }
}

对我来说它给出了以下输出,但我知道如果在 Mac 上运行会有所不同:

enter image description here

最佳答案

尝试调整 RenderingHints :

关于java - 改进旋转文本的显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12492505/

相关文章:

javascript - HTML5 Canvas - 添加更多圆圈以圆周运动旋转

java - Java 中的 JAR 级(程序集级)类作用域

java - 使用Spring Boot配置Kafka的问题

php - 读取文本文件并将内容传输到mysql数据库

iphone - 使用NSUserDefaults访问存储的对象

python - 保留以某些文本字符串开头的行

c - 将一维数组视为 C 中的二维数组以旋转图像

java - Java中如何返回数组中的位置

java - 使用 ShrinkWrap 找不到 test-persistence.xml

使用 LibGDX 相对于相机位置的 Java 旋转模型