如何删除Processing的text("text",x,y)显示的文字?
How do I delete the text which is displayed by text("text",x,y) of Processing?
我写了下面的代码,它在屏幕上延迟(故意)绘制数字 1、2、3。
void func(String s,int x,int y,int size){
fill(0);
textSize(size);
text(s,x,y);
return;
}
void setup(){
size(600,600);
}
int i=0;
void draw(){
if(i==0){f("1",100,200,30);i++;}
delay(1000);
if(i==1){f("2",100,300,30);}
delay(1000);
if(i==2){f("3",100,400,30);}
delay(1000);
}
当然这段代码最终在屏幕上显示了 3 个数字,但我想做的是通过某些函数或操作删除特定数字。
如何实施?
您不能删除显示中绘制的任何内容 window 但您可以在其上绘制一些内容或清除整个 window.
draw()
is executed continuously and the entire scene is redrawn in every frame. You don't need any delay
在 draw()
.
按background()
and use str()
清屏,将整数i
转为字符串
帧率可以通过frameRate()
设置。
看例子:
void setup(){
size(600,600);
frameRate(10);
}
int i=1;
void draw(){
background(196);
func(str(i),100,200,30);
i ++;
}
void func(String s,int x,int y,int size){
fill(0);
textSize(size);
text(s,x,y);
return;
}
我写了下面的代码,它在屏幕上延迟(故意)绘制数字 1、2、3。
void func(String s,int x,int y,int size){
fill(0);
textSize(size);
text(s,x,y);
return;
}
void setup(){
size(600,600);
}
int i=0;
void draw(){
if(i==0){f("1",100,200,30);i++;}
delay(1000);
if(i==1){f("2",100,300,30);}
delay(1000);
if(i==2){f("3",100,400,30);}
delay(1000);
}
当然这段代码最终在屏幕上显示了 3 个数字,但我想做的是通过某些函数或操作删除特定数字。
如何实施?
您不能删除显示中绘制的任何内容 window 但您可以在其上绘制一些内容或清除整个 window.
draw()
is executed continuously and the entire scene is redrawn in every frame. You don't need any delay
在 draw()
.
按background()
and use str()
清屏,将整数i
转为字符串
帧率可以通过frameRate()
设置。
看例子:
void setup(){
size(600,600);
frameRate(10);
}
int i=1;
void draw(){
background(196);
func(str(i),100,200,30);
i ++;
}
void func(String s,int x,int y,int size){
fill(0);
textSize(size);
text(s,x,y);
return;
}