增大字母后如何减小其大小?以供处理

问题描述 投票:-2回答:1

此程序打印文本。此字体大小增加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);
}
processing
1个回答
0
投票
为了控制字体大小的增加/减少,您可以将步进变量添加到应用程序的全局状态,一旦大小达到边界,只需反转步进方向即可,例如:

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); }

© www.soinside.com 2019 - 2024. All rights reserved.