Skip to content

Masking behaviour change between 1.4.1 and latest #6770

@jacopomazzoni

Description

@jacopomazzoni

Most appropriate sub-area of p5.js?

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

p5.js version

1.9.0

Web browser and version

chrome

Operating system

irrelevant/webEditor

Steps to reproduce this

Steps:

  1. old version working with 1.4.1: https://jsfiddle.net/8b253Ly1/
  2. new version no longer working , just silently failing: https://editor.p5js.org/jacopom/sketches/7SjQBqBMy
  3. same code, different lib version linked

Snippet:

var img;
var masked;

var mask;

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

		// creates an invisible graphic buffer
		// that contains a rectangle
    img = createGraphics(200, 200);
    img.rect(0, 0, 100, 100);

		// creates an invisible graphic buffer
		// that contains a circle
    mask = createGraphics(200, 200);
    mask.ellipse(100, 100, 100, 100);

		// we apply the circle in 'mask' as a clipping mask
		// to the rectangle image contained in 'img'
		// we save the result in a third buffer: 'masked'
    ( masked = img.get() ).mask( mask.get() );
}

function draw() {
    background(130,0,10);

		// print the buffer after the clipping
    image(masked, 0, 0);
}

This is something I used to teach in class, now it's broken and doesn't even give an error, what changed? how do I fix it?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions