2014-12-04 56 views
0

當按下方向鍵(+, - )時同時按下T,框架的尺寸變大,整個框架變大(黑色邊框增加),而「圖片」變小。框架尺寸變大

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

我碰到你的計劃,我仍然不知道你在問什麼。 – 2014-12-04 17:55:56

回答

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)繪製矩形與當前strokestrokeWeight值。在每一個動畫幀,內draw()方法,有:

stroke(c); 
    strokeWeight(strokeW); 

其中設置行程重量strokeW。當您按下't'信 - 這當前strokeW用於爲您rect(0,0,width,height)邊境 ...