我有以下代碼適用於旋轉文本的在線示例。代碼工作正常,因爲它旋轉文本到正確的角度,但我想知道是否有一種方法來提高旋轉文本的準確性和清晰度。在我的顯示器上,看起來好像旋轉的文本是「步進」而不是光滑的。改進旋轉文本的顯示
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上運行,這將有所不同:
爲了更好地提供幫助,請發佈[SSCCE](http://sscce.org/)。 –
也許您正在尋找反鋸齒? http://www.universalwebservices.net/web-programming-resources/java/anti-aliasing-creating-anti-alias-text-in-java – dbalakirev
我應該提到這是Processing.org代碼,因此可以複製並粘貼到IDE並運行。你是對的,我正在尋找的文本是反鋸齒的,據我瞭解它應該是。當我創建Font時,'true'選項會選擇消除鋸齒。 – user1682655