processing icon indicating copy to clipboard operation
processing copied to clipboard

shape() doesn't render anything when size parameters are specified

Open Transistorsis opened this issue 8 years ago • 4 comments

Description

When shape() (PShape) is called with size parameters, the expected result that the shape will be drawn with the specified size. However, when calling shape() with size parameters nothing is rendered.

Expected Behavior

It is expected that when the size parameters are specified, the shape will be draw at that size.

Current Behavior

The shape is not drawn at all.

Steps to Reproduce

  1. Paste the following code into the editor, and run it. When the mouse is pressed the expected output is shown, otherwise the code that doesn't work is run.

PShape square; void setup() { size(100, 100); square = createShape(RECT, 0, 0, 40, 40); square.disableStyle(); //this is to show different colors }

void draw() { background(200); if(!mousePressed) { //with no size parameters fill(100); shape(square, 10, 10); //with size parameters fill(color(255, 0, 0)); shape(square, 15, 15, 20, 20); } else { fill(100); rect(10, 10, 40, 40); fill(255, 0, 0); rect(15, 15, 20, 20); } }

Your Environment

  • Processing version: 3.3.6
  • Operating System and OS version: Windows 10, version 1703

Transistorsis avatar Nov 18 '17 18:11 Transistorsis

Re:

otherwise the code that doesn't work is run

This was hard for me to understand -- and all the colors, multiple rects, style settings etc. made it more difficult to see.

But I see it now -- this is easier for me to understand:

PShape square;
void setup() {
  size(100, 100);
  square = createShape(RECT, 0, 0, 40, 40);
}
void draw() {
  background(192);
  translate(10,20);
  if (mousePressed) {
    shape(square, 0, 0);
    text("no size (right)", 0, 0);
  } else {
    shape(square, 0, 0, 40, 40);
    text("size (wrong)", 0, 0);
  }
}

Pressing or releasing the mouse should show the same square, but it doesn't.

jeremydouglass avatar Nov 18 '17 18:11 jeremydouglass

Sorry if that was hard to understand. I seem to have difficulty expressing myself. Yes, what you have there is exactly right. (How did you get the insert code feature to work? I tried several methods, none of which worked.)

Transistorsis avatar Nov 18 '17 20:11 Transistorsis

PShape t = createShape(ELLIPSE, 0,0,100,100);
shape(t, 0,0,10,10);

This suppose to draw a smaller circle at the corner, but it is drawing nothing now. It is either a bug or something goes wrong?

tomriddle1234 avatar Nov 29 '17 05:11 tomriddle1234

Problem still exists in 4.3. Would be great if this could be fixed.

Code I used to reproduce the problem

PShape tlCorner, brCorner, bground;

void setup() {
  size(640,320);
  tile = createShape(GROUP);
  color baseColor = color(50,70,90);
  color mainColor = color(251,252,253);
    
  bground = createShape(RECT, 0, 0, 40, 40);
  bground.setFill(mainColor);
  tile.addChild(bground);
  tlCorner = createShape(ARC, 0, 0, 40, 40, 0, PI / 2);
  brCorner = createShape(ARC, 40, 40, 40, 40, PI, 3 * PI / 2);
  tlCorner.setFill(baseColor);
  brCorner.setFill(baseColor);
  tile.addChild(tlCorner);
  tile.addChild(brCorner);
}

void draw() {
  background(128);
  shape(tile, 20, 20);
  shape(tile, 340, 20, 100, 100);
}```

HartsaQ avatar Dec 28 '23 11:12 HartsaQ