p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

Enhance reference of blend() and Image.blend() and make it consistent with blendMode()

Open membralala opened this issue 1 year ago • 6 comments

Increasing access

Comprehensive examples of blend modes will provide a quick overview for people who are not used to work with image blending/layering.

Most appropriate sub-area of p5.js?

  • [ ] Accessibility
  • [ ] Color
  • [ ] Core/Environment/Rendering
  • [ ] Data
  • [ ] DOM
  • [ ] Events
  • [X] Image
  • [ ] IO
  • [ ] Math
  • [ ] Typography
  • [ ] Utilities
  • [ ] WebGL
  • [ ] Build process
  • [ ] Unit testing
  • [ ] Internationalization
  • [ ] Friendly errors
  • [ ] Other (specify if possible)

Feature enhancement details

I noticed a few small things, that might improve the documentation consistency between blend(), Image.blend() and blendMode():

  • blendMode() provides a comprehensive overview of all blend modes, while blend() and Image.blend() don't. However it might help people without experience on image blending to see, how other blend modes affect the images as well.
  • I noticed, that blend() and Image.blend() do not mention REMOVE as blend mode. However, as far as I tested it, it seems to work and acts as an inverse mask, if an image with alpha channel is provided (see example below). I wonder, if this behaviour is intentional, but if so, it probably should be documented as well.
let photo;
let maskImage;

// Load the images.
function preload() {
 photo = loadImage('/assets/rockies.jpg');
 maskImage = loadImage('/assets/mask2.png');
}

function setup() {
 createCanvas(100, 100);

 // Apply the mask.
 photo.blend(maskImage, 0, 0, 100, 100, 0, 0, 100, 100, REMOVE);

 // Display the image.
 image(photo, 0, 0);

 describe('A white canvas. The right side of the canvas has a faded patch of an image of a mountain landscape.');
Bildschirmfoto 2024-09-05 um 17 49 02
  • Also, the parameter reference of Image.blend() contains remnants of an outdated documentation including a broken link.

membralala avatar Sep 05 '24 16:09 membralala

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!

welcome[bot] avatar Sep 05 '24 16:09 welcome[bot]

Can I work on this issue?

swastikCommits avatar Mar 01 '25 03:03 swastikCommits

Hi @swastikCommits are you still interested in working on this? Adding here documentation steward @perminder-17 - is this still applicable? on 1.x or 2.x or both? Thank you!

ksen0 avatar Jun 06 '25 08:06 ksen0

You are correct @membralala , blend() and image.blend() docs needs to be updated exactly what you said on the issue. Really thanks for catching this and explaining it so well.

I think @ksen0 it's applicable in both our versions, 1.x and 2.x.

If @swastikCommits you are interested I can assign you with the issue?

perminder-17 avatar Jun 07 '25 02:06 perminder-17

Yeah, sure I would like to work on this issue!

swastikCommits avatar Jun 07 '25 02:06 swastikCommits

Yeah, sure I would like to work on this issue!

Sure, I have assigned you this. Thank you so much for taking this 🙂

perminder-17 avatar Jun 07 '25 02:06 perminder-17