2024年12月9日 星期一

wwwwwww14

001.

 PImage img;

void setup() {

  size(500, 500);

  img = createImage(500, 500, RGB);

  img.loadPixels();

  for (int i=0; i<500*500; i++) {

    img.pixels[i] = color(#FFFFF2);

  }

  img.updatePixels();

}


int x = 250, y=0;

void draw() {

  background(img);

  ellipse(x,y,20,20);

  if (y<498 && img.pixels[x+y*500]==-14) y++;

}

void mouseDragged() {

  if (mouseButton==LEFT) {

    line(mouseX, mouseY, pmouseX, pmouseY);

    loadPixels();

    for (int i=0; i<width*height; i++) {

      if (pixels[i]!=-1) pixels[i] =color(random(255), random(255), random(255));

    }

    updatePixels();

  }

  // if (mouseButton==RIGHT) {

  //  x = mouseX;

  //   y = mouseY;

  //}

}

---------------------------------------------------------------------

002.
PImage img;
void setup() {
  size(500, 500);
  img = createImage(500, 500, RGB);
  img.loadPixels();
}
ArrayList<PVector> p = new ArrayList<PVector>();
void draw() {
  background(img);
  for (PVector pp : p) {
    ellipse(pp.x, pp.y, 20, 20);
    if (pp.y<498 && img.pixels[int(pp.x)+int(pp.y)*500]==-16777216) pp.y++;
  }
}
void mouseDragged() {
  background(img);

  line(mouseX, mouseY, pmouseX, pmouseY);
  stroke(random(255), random(255), random(255));
  line(mouseX, mouseY, pmouseX, pmouseY);
  loadPixels();
  for (int i=0; i<500*500; i++) {
    img.pixels[i] = pixels[i];
  }
  img.updatePixels();
  updatePixels();
  for (PVector pp : p) {
    ellipse(int(pp.x), int(pp.y), 20, 20);
  }
}
void mousePressed() {
  if (mouseButton==RIGHT){
  p.add(new PVector(mouseX,mouseY));
  }
  
  // if (mouseButton==RIGHT) {
  //  x = mouseX;
  //   y = mouseY;
  //}
}
-------------------------------------------------------------------------
003.

沒有留言:

張貼留言