# I'm trying to repeat schultzschultzgrafik

**URL:** <https://discourse.processing.org/t/im-trying-to-repeat-schultzschultzgrafik/23872>\
**Category:** Project Guidance\
**Created:** [September 15, 2020, 12:30pm UTC](https://discourse.processing.org/t/im-trying-to-repeat-schultzschultzgrafik/23872 "2020-09-15T12:30:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![perelacha](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/perelacha/32/11873_2.png) [@perelacha](https://discourse.processing.org/u/perelacha)\
**Post date:** [September 15, 2020, 12:30pm UTC](https://discourse.processing.org/t/im-trying-to-repeat-schultzschultzgrafik/23872/1 "2020-09-15T12:30:19Z")

</div>

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

That’s what I did.

```auto
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

---

<div class="post-metadata">

**Author:** ![Hyperion65](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hyperion65/32/10569_2.png) [@Hyperion65](https://discourse.processing.org/u/Hyperion65)\
**Post date:** [September 15, 2020, 4:38pm UTC](https://discourse.processing.org/t/im-trying-to-repeat-schultzschultzgrafik/23872/2 "2020-09-15T16:38:25Z")

</div>

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.

```auto
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);  
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [September 20, 2020, 9:48pm UTC](https://discourse.processing.org/t/im-trying-to-repeat-schultzschultzgrafik/23872/3 "2020-09-20T21:48:07Z")

</div>

See also past discussions of people inspired by this work:

[https://discourse.processing.org/search?q=schultzschultzgrafik](https://discourse.processing.org/search?q=schultzschultzgrafik)

---

<div class="post-metadata">

**Author:** ![perelacha](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/perelacha/32/11873_2.png) [@perelacha](https://discourse.processing.org/u/perelacha)\
**Post date:** [February 15, 2021, 6:28pm UTC](https://discourse.processing.org/t/im-trying-to-repeat-schultzschultzgrafik/23872/4 "2021-02-15T18:28:45Z")

</div>

And now almost six months have passed, but I still haven’t figured it out. Can you give me another one hint?

```auto
PImage img;
PGraphics one;
boolean sun = false;

int size = 50;

float startX, startY;
void setup() {
  size(700,700);
  
  img = loadImage("123.jpg");
  one = createGraphics(width, height);
  
}

void draw() {
  //background(img);
  image(img,0,0);
  
  // SOURCE
  int sx = mouseX; //
  int sy = mouseY;
  int sw = mouseX - mouseX;
  int sh = mouseY - mouseY;

  // DESTINATION
  int dx = mouseX ;
  int dy = mouseY ;
  int dw = mouseX - mouseX;
  int dh = mouseY - mouseY;
      
  one.beginDraw();
  one.copy(img, sx, sy, sw, sh, dx, dy, dw, dh);
  one.endDraw();
  
 
  image(one,0,0); 
  one.beginDraw();
    if (mousePressed) {
  one.set(0, 0, img);
  one.noFill(); 
  one.stroke(#ff0000);
  one.strokeWeight(1);
  one.rect(startX,startY,mouseX - startX,mouseY -startY );
  one.endDraw();
   }
  
}

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

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [August 28, 2021, 9:49pm UTC](https://discourse.processing.org/t/im-trying-to-repeat-schultzschultzgrafik/23872/5 "2021-08-28T21:49:03Z")

</div>

I think you need to look at the video more carefully

See there is a red box when he is selecting an  
area

So I suppose click mouse, hold mouse make red rectangle, release button to define source area

Click again, draw area

Reflect this in your code please

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 29, 2021, 11:42am UTC](https://discourse.processing.org/t/im-trying-to-repeat-schultzschultzgrafik/23872/6 "2021-08-29T11:42:43Z")

</div>

Hello,

Here is an example without the mouse to get you started:

```auto
PImage img1, img2;
PGraphics pg1;

//Runs once
void setup() 
  {
  size(640, 400);
  
  img1 = loadImage("https://github.com/processing/processing-docs/blob/master/content/examples/Basics/Image/Pointillism/data/moonwalk.jpg?raw=true");  
  img2 = createImage(0, 0, RGB);
  
  pg1 = createGraphics(width, height);
  
  pg1.beginDraw();
  pg1.image(img1, 0, 0);
  pg1.endDraw();
  }

// Loops at 60 fps (frames per second)
void draw() 
  {
  background(255, 0, 0);
  image(pg1,0,0);
      
  img2 = img1.get(200, 200, 40, 40);

  pg1.beginDraw();
  //img2 = img1.get(200, 200, 40, 40);
  pg1.image(img2, 400, 360);
  
  img2 = img1.get(300, 300, 40, 40);
  //img2 = img1.get(300, 300, 40, 40).copy();
  pg1.image(img2, 200, 360);
  
  pg1.endDraw();
  }

```

You can integrate the mouse control and rectangles in the sketch window to overlay on the PGraphic.  
I removed the loop that drew the diagonal images.

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2aa42f3f8f2ae0c56faae123ed47a0d788eb038c.jpeg)

All the related tutorials, references and examples are here:

> **[Welcome to Processing!](https://processing.org)**
>
> Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Since 2001, Processing has promoted software literacy within the visual arts…

I used PImage.get():

> **[Reference](https://processing.org/reference/PImage_get_.html)**
>
> Reads the color of any pixel or grabs a section of an image. If no parameters are specified, the entire image is returned. Use the x and y parameters to get the value of one pixel. Get a…

`:)`
