当按下箭头键(+, - )同时按下T时,帧的大小变大,整个帧变大(黑边界增加),而#34;图片"变小了。
color c=color(0);
int strokeW=1,flag=0;
void setup() {
size(600, 600);
background(255);
}
void draw() {
fill(c);
stroke(c);
strokeWeight(strokeW);
if(flag==1) line(mouseX, mouseY, pmouseX, pmouseY);
}
void mouseDragged() {
flag=1;
}
void mouseReleased(){
flag=0;
}
void keyPressed() {
if (keyCode == UP) strokeW++;
if (keyCode == DOWN) strokeW--;
if (key == 'c')
background(255);
if (key == 't') {
fill(255,10); // semi-transparent white
rect(0,0,width,height);
fill(0);
//line(mouseX, mouseY, , 100);
}
if (strokeW<0)strokeW=1;
if(key== 'b')
c = color(random(0,255),random(0,255),random(0,255));
}
答案 0 :(得分:0)
你必须改变这个片段(1):
if (key == 't') {
fill(255,10); // semi-transparent white
rect(0,0,width,height);
fill(0);
}
进入(2):
if (key == 't') {
fill(255,10); // semi-transparent white
stroke(255);
strokeWeight(0);
rect(0,0,width,height);
fill(0);
}
在(1)中,您使用当前 stroke
和strokeWeight
值绘制rect。在每个动画帧中,在draw()
方法内,有:
stroke(c);
strokeWeight(strokeW);
将卒中体重设为strokeW
。当您按't'
字母时,此当前描边W 将用作rect(0,0,width,height)
边框 ...