# Extend background() for PImage

**URL:** https://discourse.processing.org/t/extend-background-for-pimage/8970
**Category:** Gallery
**Created:** [March 5, 2019, 2:53pm UTC](https://discourse.processing.org/t/extend-background-for-pimage/8970 "2019-03-05T14:53:17Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Stanlepunk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stanlepunk/32/11509_2.png) [@Stanlepunk](https://discourse.processing.org/u/Stanlepunk)
#### Post date: [March 5, 2019, 2:53pm UTC](https://discourse.processing.org/t/extend-background-for-pimage/8970/1 "2019-03-05T14:53:17Z")

</div>

`background(PImage impg, int mode)` methodes to pass PImage to background without the problem when PImage have a differente size of the window.  
With those methodes you can choice between 3 modes : CENTER, SCALE or SCREEN. When you choice SCALE you can set the position of your image, the scale and add a crutain if you want… sure that’s can be helpful.  
here you can find the example to do that :[https://github.com/StanLepunK/Rope\_examples/tree/master/IMAGE\_PGRAPHICS/background\_image](https://github.com/StanLepunK/Rope_examples/tree/master/IMAGE_PGRAPHICS/background_image)

 ![background_img_2](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7794861edb05a0875fe065073d31d61b6013a073.gif)

---

<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: [March 7, 2019, 5:56pm UTC](https://discourse.processing.org/t/extend-background-for-pimage/8970/2 "2019-03-07T17:56:05Z")

</div>

Thank you for sharing this!

> [@Stanlepunk](#):
>
> and add a crutain if you want

What does this mean?

---

<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: [March 7, 2019, 6:12pm UTC](https://discourse.processing.org/t/extend-background-for-pimage/8970/3 "2019-03-07T18:12:28Z")

</div>

I’m trying to understand the example sketch. The base sketch file background\_image.pde does not import a library – so it seems like you have added method signatures for `background` in one of the (many) tabs. But it isn’t clear where – not in FX\_background, not in core, not in Utils… where is the code? I can’t figure out how this is organized, and there are so many other things in the repo that github search doesn’t help.

---

<div class="post-metadata">

### Author: ![Stanlepunk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stanlepunk/32/11509_2.png) [@Stanlepunk](https://discourse.processing.org/u/Stanlepunk)
#### Post date: [March 7, 2019, 8:17pm UTC](https://discourse.processing.org/t/extend-background-for-pimage/8970/4 "2019-03-07T20:17:27Z")

</div>

I know it’s little complex.  
All the tab start by Z\_R is from my [rope framework](https://github.com/StanLepunK/Rope_framework) and this one imported in `Z_R_core.pde`. Rope library is for the class Vec and few Constants you can download the last build [here](https://github.com/StanLepunK/Rope/blob/master/Rope.zip). The method `background(PImage img ++) follow the main merhod`background\_calc()`in the tab`Z\_R\_Image.pde` on line 1037 🙂 I hope that’s help you to understand my mazza sketch !!!

PS : I update the exemple juste now, because there is a bug when a new `movie.mp4` is pass, because sometime the mp4 cause an PImage width and height to zero for 2 or 3 frames before work correctly.

---

<div class="post-metadata">

### Author: ![Stanlepunk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stanlepunk/32/11509_2.png) [@Stanlepunk](https://discourse.processing.org/u/Stanlepunk)
#### Post date: [March 7, 2019, 8:23pm UTC](https://discourse.processing.org/t/extend-background-for-pimage/8970/5 "2019-03-07T20:23:01Z")

</div>

a crutain mean curtain… my mistake !

---

<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: [March 7, 2019, 8:23pm UTC](https://discourse.processing.org/t/extend-background-for-pimage/8970/6 "2019-03-07T20:23:56Z")

</div>

I see! I actually have a private library called Toolboxing that has similar extension utilities.

One possible approach, based on that experience: have you considered making it a library, then importing the library jar into the sketch – either just as an import (and distribute through PDE Contributions Manager) or as a jar in the sketch folder? That would really clean up your sketch folder and make it easier to read – then the extended methods would be namespaced.

---

<div class="post-metadata">

### Author: ![Stanlepunk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stanlepunk/32/11509_2.png) [@Stanlepunk](https://discourse.processing.org/u/Stanlepunk)
#### Post date: [March 7, 2019, 8:33pm UTC](https://discourse.processing.org/t/extend-background-for-pimage/8970/7 "2019-03-07T20:33:06Z")

</div>

you’re true, I pass the class of my Rope framework step by step in my Rope library, when I’m sure the classes is robust. I don’t present my library on PDE Contribution Manager, because I don’t find a time to prepare properly. By the way I’m interreting to see your Toolboxing, and if you pick the stuff on mine you’re welcome !!!

The number of tab don’t affraid me…in my softawre Romanesco there is 100K lines of code in Processing 🙂
