有沒有辦法給 text() 背景顏色?
示例代碼:
text("Hello",20,20);
我希望這個文本有一個背景顏色。
有人可以幫我解決這個問題嗎
編輯: text() 方法在 draw()
uj5u.com熱心網友回復:
一種技術是將文本放在一個矩形中,即 text(str, x,y,w,h); 并使用 fill() 設定文本和背景顏色:
color BLUE = color(64, 124, 188);
PFont font;
void setup() {
size(400, 200);
background(255);
font = createFont("Arial", 18);
}
void draw() {
fill(BLUE); // background color
rect(60, 50, 300, 80);
textSize(24);
textAlign(CENTER, CENTER);
fill(255); //text color
text("Jeremiah was a bullfrog.", 60, 50, 300, 80);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/481913.html
上一篇:以陣列為元素的Java3D陣列
下一篇:在引數化型別上使用bound
