2021年10月4日 星期一

我出一百萬week04

 10/4 Week04

程式碼如下:

void setup(){
  size(500,500);
}
void draw(){
  if(mousePressed)background(255,0,0);
  else background(0,255,0);
}

按下滑鼠👇變紅色














對比程式碼👆👇



void setup(){
  size(500,500);
}
void draw(){
  if(mousePressed)line(mouseX,mouseY,0,0);
}

👇類似小畫家可畫細線👀





















void setup(){
  size(500,500);
}
void draw(){
  if(mousePressed)line(mouseX,mouseY,pmouseX,mouseY);
}


















void setup(){
  size(500,500);
  fill(255,0,0); rect(0,0,100,100);//紅色
  fill(0,255,0);rect(0,100,100,100);//綠色
}
void draw(){
  if(mousePressed){
    if(mouseX<100){
      if(mouseY<100) stroke(255,0,0);//紅色
      else if(mouseY<200) stroke(0,255,0);//綠色
    }else line(mouseX,mouseY,pmouseX,pmouseY);
  }
}
















void setup(){
  size(500,500);
  rect(0,0,100,100); ellipse(50,50,8,8);//8的圓
  rect(0,100,100,100); ellipse(50,150,4,4);//4的圓
}
void draw(){
  if(mousePressed){
    if(mouseX<100){
      if(mouseY<100) strokeWeight(8);//粗
      else if(mouseY<200) strokeWeight(4);//中
    }else line(mouseX,mouseY,pmouseX,pmouseY);
  }
}
















void setup(){
  size(500,500);
  rect(0, 50, 50,50); ellipse(25,25+50,1,1);
  rect(0,100, 50,50); ellipse(25,25+100,2,2);
  rect(0,150, 50,50); ellipse(25,25+150,3,3);
  rect(0,200, 50,50); ellipse(25,25+200,4,4);
  rect(0,250, 50,50); ellipse(25,25+250,5,5);
  rect(0,300, 50,50); ellipse(25,25+300,6,6);
  rect(0,350, 50,50); ellipse(25,25+350,7,7);
  rect(0,400, 50,50); ellipse(25,25+400,8,8);
}
void draw(){
  if(mousePressed){
    if(mouseX<50){
      if(mouseY>1*50 && mouseY<1*50+50) strokeWeight(1);
      if(mouseY>2*50 && mouseY<2*50+50) strokeWeight(2);
      if(mouseY>3*50 && mouseY<3*50+50) strokeWeight(3);
      if(mouseY>4*50 && mouseY<4*50+50) strokeWeight(4);
      if(mouseY>5*50 && mouseY<5*50+50) strokeWeight(5);
      if(mouseY>6*50 && mouseY<6*50+50) strokeWeight(6);
      if(mouseY>7*50 && mouseY<7*50+50) strokeWeight(7);
      if(mouseY>8*50 && mouseY<8*50+50) strokeWeight(8);
    }else line(mouseX,mouseY,pmouseX,pmouseY);
  }
}

















void setup(){
  size(500,500);
  fill(#E82B05); rect(0, 50, 50, 50);
  fill(#FF801F); rect(0, 100, 50, 50);
  fill(#FEFF00); rect(0, 150, 50, 50);
  fill(#21FF00); rect(0, 200, 50, 50);
  fill(#00E3FF); rect(0, 250, 50, 50);
  fill(#0024FF); rect(0, 300, 50, 50);
  fill(#9C00FF); rect(0, 350, 50, 50);
  fill(#FF6CA0); rect(0, 400, 50, 50);
}
void draw(){
  if(mousePressed){
    if(mouseX<50){
      if(mouseY>1*50 && mouseY<1*50+50) stroke(#E82B05);
      if(mouseY>2*50 && mouseY<2*50+50) stroke(#FF801F);
      if(mouseY>3*50 && mouseY<3*50+50) stroke(#FEFF00);
      if(mouseY>4*50 && mouseY<4*50+50) stroke(#21FF00);
      if(mouseY>5*50 && mouseY<5*50+50) stroke(#00E3FF);
      if(mouseY>6*50 && mouseY<6*50+50) stroke(#0024FF);
      if(mouseY>7*50 && mouseY<7*50+50) stroke(#9C00FF);
      if(mouseY>8*50 && mouseY<8*50+50) stroke(#FF6CA0);
    }else line(mouseX,mouseY,pmouseX,pmouseY);
  }
}















void setup(){
  size(500,500);
  rect(0, 50, 50,50); ellipse(25,25+50,1,1);
  rect(0,100, 50,50); ellipse(25,25+100,2,2);
  rect(0,150, 50,50); ellipse(25,25+150,3,3);
  rect(0,200, 50,50); ellipse(25,25+200,4,4);
  rect(0,250, 50,50); ellipse(25,25+250,5,5);
  rect(0,300, 50,50); ellipse(25,25+300,6,6);
  rect(0,350, 50,50); ellipse(25,25+350,7,7);
  rect(0,400, 50,50); ellipse(25,25+400,8,8);
  fill(#E82B05); rect(450, 50, 50, 50);
  fill(#FF801F); rect(450, 100, 50, 50);
  fill(#FEFF00); rect(450, 150, 50, 50);
  fill(#21FF00); rect(450, 200, 50, 50);
  fill(#00E3FF); rect(450, 250, 50, 50);
  fill(#0024FF); rect(450, 300, 50, 50);
  fill(#9C00FF); rect(450, 350, 50, 50);
  fill(#FF6CA0); rect(450, 400, 50, 50);
}
void draw(){
  if(mousePressed){
    if(mouseX<50){
      if(mouseY>1*50 && mouseY<1*50+50) strokeWeight(1);
      if(mouseY>2*50 && mouseY<2*50+50) strokeWeight(2);
      if(mouseY>3*50 && mouseY<3*50+50) strokeWeight(3);
      if(mouseY>4*50 && mouseY<4*50+50) strokeWeight(4);
      if(mouseY>5*50 && mouseY<5*50+50) strokeWeight(5);
      if(mouseY>6*50 && mouseY<6*50+50) strokeWeight(6);
      if(mouseY>7*50 && mouseY<7*50+50) strokeWeight(7);
      if(mouseY>8*50 && mouseY<8*50+50) strokeWeight(8);
    }else if(mouseX>450){
      if(mouseY>1*50 && mouseY<1*50+50) stroke(#E82B05);
      if(mouseY>2*50 && mouseY<2*50+50) stroke(#FF801F);
      if(mouseY>3*50 && mouseY<3*50+50) stroke(#FEFF00);
      if(mouseY>4*50 && mouseY<4*50+50) stroke(#21FF00);
      if(mouseY>5*50 && mouseY<5*50+50) stroke(#00E3FF);
      if(mouseY>6*50 && mouseY<6*50+50) stroke(#0024FF);
      if(mouseY>7*50 && mouseY<7*50+50) stroke(#9C00FF);
      if(mouseY>8*50 && mouseY<8*50+50) stroke(#FF6CA0);
    }else line(mouseX,mouseY,pmouseX,pmouseY);
  }
}

沒有留言:

張貼留言