I'm trying to repeat schultzschultzgrafik

Hello. I am new to coding.
I’m trying to repeat schultzschultzgrafik https://www.instagram.com/p/CD4h9QCirXH/

That’s what I did.

PImage img; 
float xStep, yStep;
int xCount = 100;
int yCount = 100;
int m = 10, s = 5, px, py; 
float startX, startY;
PImage selection;
int direction = 1;
float signal;



void setup() {
  size(800, 800); 
  img = loadImage("1.jpg");
  img.resize(800, 800);
 
  
  
}
void draw(){
  background(img);
  fill(#ffffff);
  noStroke();
  ellipse(mouseX, mouseY, 10, 10); 
  if(mousePressed) {
    noFill();
    strokeWeight(3);
    stroke(255, 100);
    rectMode(CORNER);
    rect(startX, startY, mouseX-startX, mouseY-startY); 
  }
  
}

void mousePressed() {
  startX=mouseX;
  startY=mouseY;
}

void mouseReleased() {
  if(mouseButton==RIGHT && selection!=null) {  
    set(mouseX, mouseY, selection); 
    img=get();
  }
  
  else selection=get((int)startX, (int)startY, (int)(abs(startX-mouseX)), (int)(abs(startY-mouseY))); 
   

if (signal > img.height/2 || signal < 0) { 
    direction = direction / -1;
  }
  if (mousePressed == true) {
    signal = abs(mouseY % img.height);
  } 
  else {
    signal += (0.3*direction);
  }

  if (keyPressed == true) {
  set(0, 0, img);

    
    // SOURCE   
      int sx = px; 
      int sy = py;
      int sw = int(startX*2);
      int sh = int(startY*2);


      // DESTINATION
      int dx = px;
      int dy = py;
      int dw = int(mouseX);
      int dh = int(mouseY);
      
      copy(img, sx, sy, sw, sh, dx, dy, dw, dh);
 }
 }

Tell me how to copy the selected area

1 Like

your wish is my command !
you will probably want to use a PGraphics, since “normal” copy copies into the display window.
then you can put the PGraphics to wherever you like (e.g. move it with the mouse.

PImage img;
PGraphics one;

void setup() {
  size(400,600);
  
  img = loadImage("woman.png");
  one  = createGraphics(width, height);
}

void draw() {
  one.beginDraw();
  one.copy(img,100,50,100,100,100,50,100,100);
  one.endDraw();  
  image(one,0,0);  
}
1 Like

See also past discussions of people inspired by this work:

https://discourse.processing.org/search?q=schultzschultzgrafik