# Drawing PImages or PShapes with color modulation

**URL:** <https://discourse.processing.org/t/drawing-pimages-or-pshapes-with-color-modulation/29052>\
**Category:** Coding Questions\
**Created:** [April 1, 2021, 5:07pm UTC](https://discourse.processing.org/t/drawing-pimages-or-pshapes-with-color-modulation/29052 "2021-04-01T17:07:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [April 1, 2021, 5:07pm UTC](https://discourse.processing.org/t/drawing-pimages-or-pshapes-with-color-modulation/29052/1 "2021-04-01T17:07:00Z")

</div>

is there any native way to print a PImage (or a PShape) with additional arguments to change the hue saturation or brightness? i would love to be able to do like image(file,x,y,w,h,hueShift,saturationShift,brightnessShift) or maybe premptively create new image variables with the modified values like PImage new = hueShift(old,ammount), does something like this exist? if not, is there any way i can access the native code for printing images to mod it myself? thanks

---

<div class="post-metadata">

**Author:** ![ReyzArtz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/reyzartz/32/11750_2.png) [@ReyzArtz](https://discourse.processing.org/u/ReyzArtz)\
**Post date:** [April 1, 2021, 5:46pm UTC](https://discourse.processing.org/t/drawing-pimages-or-pshapes-with-color-modulation/29052/2 "2021-04-01T17:46:14Z")

</div>

Hey Canslp,  
you can try watching this tutorial if u want to have a better understanding of how to work with pixel  
and for changing the hue of a picture try writing a function to shift the hue of the individual pixel then update the pixels with the new value

[![](https://img.youtube.com/vi/j-ZLDEnhT3Q/hqdefault.jpg "10.5: Image Processing with Pixels - Processing Tutorial") ](https://www.youtube.com/watch?v=j-ZLDEnhT3Q)

---

<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:** [April 1, 2021, 5:52pm UTC](https://discourse.processing.org/t/drawing-pimages-or-pshapes-with-color-modulation/29052/3 "2021-04-01T17:52:56Z")

</div>

Hello,

To list a few…

Some resources:

- [Images and Pixels \ Processing.org](https://processing.org/tutorials/pixels/)
- [Color \ Processing.org](https://processing.org/tutorials/color/)
- [Color Gradients in Processing (v 2.0) | by Jeremy Behreandt | Medium](https://behreajj.medium.com/color-gradients-in-processing-v-2-0-e5c0b87cdfd2)

Examples that come with Processing:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e44b73ebb859099ca81b96c8520aa6f6121e3823.png)

`:)`

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [April 1, 2021, 9:55pm UTC](https://discourse.processing.org/t/drawing-pimages-or-pshapes-with-color-modulation/29052/4 "2021-04-01T21:55:19Z")

</div>

i mean i suppose i could manually create variants for each image. say i have a bunch of tile textures and i want to be able to change the color pallet of a scene (so i need to change the color of the texture images), should i create new image files preemptively? or is there a more native way to do it

---

<div class="post-metadata">

**Author:** ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)\
**Post date:** [April 2, 2021, 3:34am UTC](https://discourse.processing.org/t/drawing-pimages-or-pshapes-with-color-modulation/29052/5 "2021-04-02T03:34:14Z")

</div>

You might look into Blend Modes, which can be toggled on/off whenever you want, which I think would fit the bill here.

If you want to get reallllly nitty gritty, you could look into writing a custom shader 🤔

---

<div class="post-metadata">

**Author:** ![ReyzArtz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/reyzartz/32/11750_2.png) [@ReyzArtz](https://discourse.processing.org/u/ReyzArtz)\
**Post date:** [April 2, 2021, 4:52am UTC](https://discourse.processing.org/t/drawing-pimages-or-pshapes-with-color-modulation/29052/6 "2021-04-02T04:52:20Z")

</div>

if u want to create different varient of each image u can preporcess the and save the images before runnung the animation

---

<div class="post-metadata">

**Author:** ![Milchreis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/milchreis/32/7058_2.png) [@Milchreis](https://discourse.processing.org/u/Milchreis)\
**Post date:** [April 2, 2021, 7:38am UTC](https://discourse.processing.org/t/drawing-pimages-or-pshapes-with-color-modulation/29052/7 "2021-04-02T07:38:53Z")

</div>

Hi,

maybe the ColorShift class of my image-processing library could help:

> **[Milchreis/processing-imageprocessing - Color shift image](https://github.com/Milchreis/processing-imageprocessing#color-shift-image)**
>
> Collection of basic image processing algorithms for processing

```auto
// hue is a value between 0 and 360
// offset is the color range which is accepted (in hue range)
// shift is the number of the subtracted or added hue value
PImage processedImage = ColorShift.applyHue(image, hue, offset, shift); 

```

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [April 2, 2021, 3:05pm UTC](https://discourse.processing.org/t/drawing-pimages-or-pshapes-with-color-modulation/29052/8 "2021-04-02T15:05:35Z")

</div>

oh sweet that looks really helpful- is it just for raster pimages?

---

<div class="post-metadata">

**Author:** ![Milchreis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/milchreis/32/7058_2.png) [@Milchreis](https://discourse.processing.org/u/Milchreis)\
**Post date:** [April 2, 2021, 3:28pm UTC](https://discourse.processing.org/t/drawing-pimages-or-pshapes-with-color-modulation/29052/9 "2021-04-02T15:28:25Z")

</div>

Yes, it’s for raster images, especially PImage, only. But you can use the Tools class for color calculations:

> <https://github.com/Milchreis/processing-imageprocessing/blob/master/src/milchreis/imageprocessing/utils/Tools.java#L124>

```auto
Tools.rgbToHsb(r, g, b);

```

After that you can change the hue value and add it to your shape.
