# Stamp tool in processing

**URL:** <https://discourse.processing.org/t/stamp-tool-in-processing/10298>\
**Category:** Coding Questions\
**Created:** [April 15, 2019, 3:46pm UTC](https://discourse.processing.org/t/stamp-tool-in-processing/10298 "2019-04-15T15:46:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![helen1216](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/helen1216/32/4633_2.png) [@helen1216](https://discourse.processing.org/u/helen1216)\
**Post date:** [April 15, 2019, 3:46pm UTC](https://discourse.processing.org/t/stamp-tool-in-processing/10298/1 "2019-04-15T15:46:06Z")

</div>

Hi, I want to know if this idea is possible. I am trying to create a random stamping tool if I do a key press.

1. I want to know if it’s possible to create a stamping tool based on newly created image like this.

 ![37%20AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3badfa74d4029f9661fe6da4ebba94fd910675c6.png)

Now, I only can stamp(copy) based on the original image. This the coding what I have.

```auto
PImage typecopy;

void setup() {
  size(500,500);
  frameRate(10);
  typecopy = loadImage("type.png");
  background(255);
  image(typecopy, 0, 0);
 }

void draw() {
 image(typecopy, 0, 0);
 
//if keypress u,j , copy part of image
 if(keyPressed==true){ 
 //for(int i = 0; i <20;i++);
 if (key=='u' || key=='U'){
 typecopy.copy(int(random(width)), int(random(height)),200, 200, int(random(width)), int(random(height)),200,200);
 loadPixels(); 
 pixels[int(random(200))] = color(0); 
 updatePixels();
}
}
}

```

1. Also, I want to know if I can make a stamp tool in circle shape.

---

<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:** [April 20, 2019, 4:46am UTC](https://discourse.processing.org/t/stamp-tool-in-processing/10298/2 "2019-04-20T04:46:57Z")

</div>

Yes, you can.

1. create a circular mask

```auto
PImage stamp;
PGraphics maskImage;
void setup() {
  size(512, 512);
  stamp = loadImage("https://forum.processing.org/processing-org.jpg");
  // create mask
  maskImage = createGraphics(512,512);
  maskImage.beginDraw();
  maskImage.ellipse(256, 256, 400, 400);
  maskImage.endDraw();
  // apply mask
  stamp.mask(maskImage);
}
void draw() {
  // show masked image
  image(stamp, 0, 0);
}

```

It looks like free rotating the stamp is also important to your “circular effect”. You can do that by translating to the center of the stamp position, rotating, and then translating back by half the stamp width/height.

```auto
void draw() {
  // show masked image
  translate(width/2,height/2);
  rotate(millis()*0.001);
  image(stamp, -stamp.width/2, -stamp.height/2);
}

```

…or use `imageMode(CENTER)` and just rotate.

I’m not sure that I understand your sampling question, but the key is to not copy the source onto itself – instead, draw the source onto the canvas, then copy part of the canvas onto the stamp. Then stamp the canvas… then copy part of the canvas onto the stamp. Then stamp the canvas… then copy part of the canvas onto the stamp. You don’t ever need to alter the source image.

---

<div class="post-metadata">

**Author:** ![helen1216](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/helen1216/32/4633_2.png) [@helen1216](https://discourse.processing.org/u/helen1216)\
**Post date:** [April 22, 2019, 5:03pm UTC](https://discourse.processing.org/t/stamp-tool-in-processing/10298/3 "2019-04-22T17:03:30Z")

</div>

Thank you so much!!! This is cool!!!
