Processing 增加字母后,如何减小字母的大小?用于处理

Processing 增加字母后,如何减小字母的大小?用于处理,processing,Processing,这个程序可以打印文本。此字体大小从5增加到250。字体大小为250时,此字体大小将从250减小到5。然后,当字体大小为5时,该字体大小将增加5到250。 字体大小为5。 下面的代码是我制作的。 然而,我无法在提高字母后减小字母的大小 PFont myFont; int ts= 5; int ts2 = 250; float x, y; void setup() { size(500, 500); x = width/2; y = height/2; myFont = loadFont

这个程序可以打印文本。此字体大小从5增加到250。字体大小为250时,此字体大小将从250减小到5。然后,当字体大小为5时,该字体大小将增加5到250。 字体大小为5。 下面的代码是我制作的。 然而,我无法在提高字母后减小字母的大小

PFont myFont;
int ts= 5;
int ts2 = 250;
float x, y;


void setup() {
 size(500, 500);
 x = width/2;
 y = height/2;
 myFont = loadFont("휴먼가는샘체-48.vlw");
 textFont(myFont);
 fill(255);
}

void draw() {
 background(180);
 textSize(ts);
 textAlign(CENTER);
 text("이재용", x, y);
 ts+=5;
 delay(100);
}

为了控制字体大小的增加/减少,您可以向应用程序的全局状态添加一个步长变量,一旦大小达到边界,只需反转步长方向,例如:

PFont myFont;
int ts= 5;
int step = 5;
int ts2 = 250;
float x, y;

void setup() {
 size(500, 500);
 x = width/2;
 y = height/2;
 myFont = createFont("Georgia", 32);
 textFont(myFont);
 fill(255);
}

void draw() {
 background(180);
 textSize(ts);
 textAlign(CENTER);
 text("gf", x, y);

 if(ts>=250){
   step = -5;
 }else if(ts<=5){
   step = 5;
 }

 ts+=step;
 delay(100);
}

到目前为止,您尝试了什么?请访问并检查我编辑的问题请再次检查我的问题@black0ut有关您环境的更多信息将有所帮助。也就是说,这是什么语言?您在标题中提到了处理,但在问题本身中再次更清楚地提到它是有帮助的。