2014-12-04 105 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)边境 ...