Open
Description
Most appropriate sub-area of Processing 4?
Image, Core/Environment/Rendering
Processing version
4.4.3
Operating system
macOS
Steps to reproduce this
Run the following snippet.
Using mask()
to mask an image leads to mask() can only be used with an image that's the same size.
though both images are created with same size. Worked until 4.4.2.
snippet
PImage img;
void setup() {
size(150, 150);
setupHexagon(50);
hexagon(75, 75, 50);
}
void draw() {
}
private void setupHexagon(int radius) {
noiseSeed(1004);
img = createImage(radius*2, radius*2, RGB);
for (int px = 0; px < img.width; px++) {
for (int py = 0; py < img.height; py++) {
float n = noise(px/(float)img.width, py/(float)img.height);
img.pixels[px+py*img.width] = color(n*255);
}
}
img.updatePixels();
PShape s = createShape();
s.beginShape();
s.fill(255);
for (int i=0; i<6; i++)
s.vertex(cos(PI/3*i) * radius, sin(PI/3*i) * radius);
s.endShape(CLOSE);
PGraphics maskImage;
maskImage = createGraphics(img.width, img.height);
maskImage.beginDraw();
maskImage.shape(s, img.width/2., img.height/2.);
maskImage.endDraw();
img.mask(maskImage);
}
private void hexagon(float x, float y, float radius) {
imageMode(CENTER);
image(img, x, y, 2*radius, 2*radius);
}
Additional context
Snippet draws a hexagon with noisy pattern.
Would you like to work on the issue?
assign to someone else, please