void setup(){
size(800,800);
}
void draw(){
background(#F0D079);
noFill();
strokeWeight(6);
rect(50,50,720,720);
strokeWeight(1);
for(int i=0;i<9;i++){
line(50,50+i*80,770,50+i*80);
line(50+i*80,50,50+i*80,770);
}
}
int nowX,nowY;
void setup(){
size(800,800);
}
void draw(){
background(#F0D079);
noFill();
strokeWeight(6);
rect(50,50,720,720);
strokeWeight(1);
for(int i=0;i<9;i++){
line(50,50+i*80,770,50+i*80);
line(50+i*80,50,50+i*80,770);
}
fill(255,0,0);
ellipse (nowX*80+50,nowY*80+50,80,80);
}
void mouseMoved(){
nowX = (mouseX-50)/80;
nowY = (mouseY-50)/80;
println(" mouseX: " + mouseX + " mouseY: " + mouseY + " nowX: " + nowX + " nowY: " + nowY);
}
int myColor=1;
int nowX,nowY;
int [][] array = new int [10][10];
void setup(){
size(800,800);
}
void draw(){
background(#F0D079);
noFill();
strokeWeight(6);
rect(50,50,720,720,10);
strokeWeight(1);
for(int i=0;i<10;i++){
line(50,50+i*80,770,50+i*80);
line(50+i*80,50,50+i*80,770);
}
fill(255,0,0);
ellipse(nowX*80+50,nowY*80+50,80,80);
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
if(array[i][j]==1){fill(0); ellipse(i*80+50,j*80+50,80,80);}
if(array[i][j]==2){fill(255); ellipse(i*80+50,j*80+50,80,80);}
}
}
}
void mousePressed(){
array[nowX][nowY]=myColor;
if(myColor==1)myColor=2;
else if(myColor==2)myColor=1;
}
void mouseMoved(){
nowX = (mouseX)/80;
nowY = (mouseY)/80;
println(" mouseX: " + mouseX + " mouseY: " + mouseY + " nowX: " + nowX + " nowY: " + nowY);
}
沒有留言:
張貼留言