# Blending two PGraphics - how would this work? - what is the syntax?

**URL:** <https://discourse.processing.org/t/blending-two-pgraphics-how-would-this-work-what-is-the-syntax/25630>\
**Category:** Beginners\
**Created:** [November 23, 2020, 11:09am UTC](https://discourse.processing.org/t/blending-two-pgraphics-how-would-this-work-what-is-the-syntax/25630 "2020-11-23T11:09:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MuddyGardener](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/muddygardener/32/1719_2.png) [@MuddyGardener](https://discourse.processing.org/u/MuddyGardener)\
**Post date:** [November 23, 2020, 11:09am UTC](https://discourse.processing.org/t/blending-two-pgraphics-how-would-this-work-what-is-the-syntax/25630/1 "2020-11-23T11:09:52Z")

</div>

The Processing reference for blend suggests there is flexibility of specifying the destination image as well as the source image.

[\> Blends a region of pixels from one image into another (or in itself again) with full alpha channel support. There is a choice of the following modes to blend the source pixels (A) with the ones of pixels in the destination image (B)](https://processing.org/reference/blend_.html)

But in the syntax you only get to specify the source image. The destination image seems hardwired to be the image in the sketch window.

But what if I want the destination image to be another PGraphics? Can I do this? What would be the syntax?

thanks!

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [November 23, 2020, 11:55am UTC](https://discourse.processing.org/t/blending-two-pgraphics-how-would-this-work-what-is-the-syntax/25630/2 "2020-11-23T11:55:58Z")

</div>

You can call `blend()` on a `PGraphics` object.

---

<div class="post-metadata">

**Author:** ![MuddyGardener](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/muddygardener/32/1719_2.png) [@MuddyGardener](https://discourse.processing.org/u/MuddyGardener)\
**Post date:** [November 23, 2020, 2:33pm UTC](https://discourse.processing.org/t/blending-two-pgraphics-how-would-this-work-what-is-the-syntax/25630/3 "2020-11-23T14:33:41Z")

</div>

Aha, good. What is the syntax? As I said, the Processing documentation for Blend just tells you how to specify source, not the destination. And in the examples it’s aways the Pimage that’s being operated on. How would you get it to operate on a PGraphics that you specify?

---

<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:** [November 23, 2020, 2:43pm UTC](https://discourse.processing.org/t/blending-two-pgraphics-how-would-this-work-what-is-the-syntax/25630/4 "2020-11-23T14:43:09Z")

</div>

img1.blend(img2,…);

---

<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:** [November 23, 2020, 4:13pm UTC](https://discourse.processing.org/t/blending-two-pgraphics-how-would-this-work-what-is-the-syntax/25630/5 "2020-11-23T16:13:27Z")

</div>

```auto

PImage c1, c2; 

void setup() {
  size(500, 500);

  c1 = loadImage("c1.jpg");
  c2 = loadImage("c2.jpg");
}

void draw() {

  image(c1, 0, 0);

  c1.blend(c2, 
    mouseX, mouseY, 100, 100, 
    mouseX, mouseY, 100, 100, 
    DARKEST); // LIGHTEST

  image(c1, 0, 0);
}

```

---

<div class="post-metadata">

**Author:** ![MuddyGardener](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/muddygardener/32/1719_2.png) [@MuddyGardener](https://discourse.processing.org/u/MuddyGardener)\
**Post date:** [November 23, 2020, 4:32pm UTC](https://discourse.processing.org/t/blending-two-pgraphics-how-would-this-work-what-is-the-syntax/25630/6 "2020-11-23T16:32:54Z")

</div>

Great your example is the answer to the question I meant to ask!

---

<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:** [November 24, 2020, 12:16pm UTC](https://discourse.processing.org/t/blending-two-pgraphics-how-would-this-work-what-is-the-syntax/25630/7 "2020-11-24T12:16:00Z")

</div>

Hello,

References are here for PImage blend():  
_[https://processing.org/reference/PImage.html](https://processing.org/reference/PImage.html)_ \< blend method is listed  
_[https://processing.org/reference/PImage\_blend\_.html](https://processing.org/reference/PImage_blend_.html)_

Reference to blend():  
_[https://processing.org/reference/blend\_.html](https://processing.org/reference/blend_.html)_

`:)`
