processing / p5.js

p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. http://twitter.com/p5xjs —
http://p5js.org/
GNU Lesser General Public License v2.1
21.74k stars 3.34k forks source link

push() ignores the _colorMaxes field set by colorMode() #7402

Open zeesworth opened 2 days ago

zeesworth commented 2 days ago

Most appropriate sub-area of p5.js?

p5.js version

v1.11.0

Web browser and version

Firefox 128.5.1esr

Operating system

Windows 10

Steps to reproduce this

Steps:

  1. Call push()
  2. Call colorMode() with a non-default max color value
  3. Call pop(), all color calls after that will still continue to use the max color values specified in the push() section

Snippet:

function draw() {
  colorMode(RGB, 1.0); 
  background(0.5);

  push();
  //colorMode(RGB, 0.5); // Uncomment me for fun and bugs
  pop();

  textSize(32);
  fill(0.5);
  text('Oh no', 50, 50);
}
welcome[bot] commented 2 days ago

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!

zeesworth commented 2 days ago

Looking at the code responsible for push(), it seems like it would be a very simple change to make the function hold onto the value of _colorMaxes too. I would be happy to submit a change that fixes this bug, if this is considered an issue.