# How do I use a method in other Processing projects?

**URL:** <https://discourse.processing.org/t/how-do-i-use-a-method-in-other-processing-projects/37863>\
**Category:** Coding Questions\
**Created:** [July 6, 2022, 7:35pm UTC](https://discourse.processing.org/t/how-do-i-use-a-method-in-other-processing-projects/37863 "2022-07-06T19:35:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Random\_Ghost](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/random_ghost/32/16609_2.png) [@Random\_Ghost](https://discourse.processing.org/u/Random_Ghost)\
**Post date:** [July 6, 2022, 7:35pm UTC](https://discourse.processing.org/t/how-do-i-use-a-method-in-other-processing-projects/37863/1 "2022-07-06T19:35:02Z")

</div>

I created a function that takes an image and returns a similar version of the image but with Gameboy graphics. Is there a way I can sort of save the function so I can use it in other projects similar to the way we use functions like circle(x, y, d)?  
Here’s the function in case you need it:

```
PImage gameboyRenderer(PImage real){
  PImage image = createImage(real.width, real.height, RGB);
  image.copy(real, 0, 0, real.width, real.height, 0, 0, real.width, real.height);
  for(int y = 0; y < image.height - 1; y++){
    for(int x = 1; x < image.width - 1; x++){
      color pix = image.pixels[index(x, y)];
      float scale = 3;
      
      float oldR = red(pix);
      float oldG = green(pix);
      float oldB = blue(pix);
      
      float newR = (255 / scale) * round(scale * oldR / 255.0);
      float newG = (255 / scale) * round(scale * oldG / 255.0);
      float newB = (255 / scale) * round(scale * oldB / 255.0);
      image.pixels[index(x, y)] = color(newR, newG, newB);
      
      float errR = oldR - newR;
      float errG = oldG - newG;
      float errB = oldB - newB;
      
      int index = index(x + 1, y );
      color c = image.pixels[index];
      float r = red(c);
      float g = green(c);
      float b = blue(c);
      r = r + errR * 7 / 16.0;
      g = g + errG * 7 / 16.0;
      b = b + errB * 7 / 16.0;
      image.pixels[index] = color(r, g, b);
      
      index = index(x - 1, y + 1);
      c = image.pixels[index];
      r = red(c);
      g = green(c);
      b = blue(c);
      r = r + errR * 3 / 16.0;
      g = g + errG * 3 / 16.0;
      b = b + errB * 3 / 16.0;
      image.pixels[index] = color(r, g, b);
      
      index = index(x , y + 1);
      c = image.pixels[index];
      r = red(c);
      g = green(c);
      b = blue(c);
      r = r + errR * 5 / 16.0;
      g = g + errG * 5 / 16.0;
      b = b + errB * 5 / 16.0;
      image.pixels[index] = color(r, g, b);
      
      index = index(x + 1, y + 1);
      c = image.pixels[index];
      r = red(c);
      g = green(c);
      b = blue(c);
      r = r + errR * 1 / 16.0;
      g = g + errG * 1 / 16.0;
      b = b + errB * 1 / 16.0;
      image.pixels[index] = color(r, g, b);
    }
  }
```

---

<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:** [July 6, 2022, 9:39pm UTC](https://discourse.processing.org/t/how-do-i-use-a-method-in-other-processing-projects/37863/2 "2022-07-06T21:39:50Z")

</div>

Just copy the function to your new sketch

Other way is to make a library that you can use from different sketches
