Stamp tool in processing

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.

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

PImage typecopy;

void setup() {
  typecopy = loadImage("type.png");
  image(typecopy, 0, 0);

void draw() {
 image(typecopy, 0, 0);
//if keypress u,j , copy part of image
 //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);
 pixels[int(random(200))] =  color(0); 
  1. Also, I want to know if I can make a stamp tool in circle shape.

Yes, you can.

  1. create a circular mask
PImage stamp;
PGraphics maskImage;
void setup() {
  size(512, 512);
  stamp = loadImage("");
  // create mask
  maskImage = createGraphics(512,512);
  maskImage.ellipse(256, 256, 400, 400);
  // apply mask
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.

void draw() {
  // show masked image
  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.


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