New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

radius for rect not working on PShape #2646

Closed
clankill3r opened this Issue Jul 23, 2014 · 8 comments

Comments

Projects
None yet
4 participants
@clankill3r

clankill3r commented Jul 23, 2014

Since we have round corners now it would be nice if that also works with createShape.
I looked in the code and I can understand it's a bit tricky to do.

Also shouldn't rectMode etc. not influence the createShape? I guess it would make sense.

PShape square;  // The PShape object

void setup() {
  size(100, 100, P2D);
  rectMode(CENTER);

  square = createShape(RECT, 0, 0, 50, 50, 17); // <<<<<<<<<<<<<<<
  square.setFill(color(0, 0, 255));
  square.setStroke(false);
}

void draw() {
  shape(square, 25, 25);
}
@JakubValtar

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Jul 25, 2014

Contributor

This is more of a problem with reference. There are four ways how to create a RECT shape. However, the reference says that they are the same as rect() function, which is not correct. The reference should be updated to better reflect this.

createShape(RECT, x1, y1, x2, y2);
createShape(RECT, x1, y1, x2, y2, mode);
createShape(RECT, x1, y1, x2, y2, tl, tr, br, bl);
createShape(RECT, x1, y1, x2, y2, tl, tr, br, bl, mode);
// mode - CORNER, CORNERS, RADIUS, CENTER
// tl, tr, br, bl - radii for each corner

There is, however, another bug which happens when you try to create rect with rounded corners with above methods. I will fill in another issue where I will describe it.

Contributor

JakubValtar commented Jul 25, 2014

This is more of a problem with reference. There are four ways how to create a RECT shape. However, the reference says that they are the same as rect() function, which is not correct. The reference should be updated to better reflect this.

createShape(RECT, x1, y1, x2, y2);
createShape(RECT, x1, y1, x2, y2, mode);
createShape(RECT, x1, y1, x2, y2, tl, tr, br, bl);
createShape(RECT, x1, y1, x2, y2, tl, tr, br, bl, mode);
// mode - CORNER, CORNERS, RADIUS, CENTER
// tl, tr, br, bl - radii for each corner

There is, however, another bug which happens when you try to create rect with rounded corners with above methods. I will fill in another issue where I will describe it.

@alignedleft

This comment has been minimized.

Show comment
Hide comment
@alignedleft

alignedleft Jul 26, 2014

Member

@JakubValtar where do you see this problem in the reference? Is this the page you think should be updated?

http://processing.org/reference/createShape_.html

I suspect you're referring to this paragraph:

The createShape() function is used to define a new shape. Once created, this shape can be drawn with the shape() function. The basic way to use the function defines new primitive shapes. One of the following parameters are used as the first parameter: ELLIPSE, RECT, ARC, TRIANGLE, SPHERE, BOX, QUAD, LINE. The parameters for each of these different shapes are the same as their corresponding functions: ellipse(), rect(), arc(), triangle(), sphere(), box(), and line(). The first example above clarifies how this works.

If so, please resolve the rounded corners bug first #2648 then if the documentation needs to be updated to sync with the (fixed) functionality, post an issue to: https://github.com/processing/processing-docs/issues/

Thanks!

Member

alignedleft commented Jul 26, 2014

@JakubValtar where do you see this problem in the reference? Is this the page you think should be updated?

http://processing.org/reference/createShape_.html

I suspect you're referring to this paragraph:

The createShape() function is used to define a new shape. Once created, this shape can be drawn with the shape() function. The basic way to use the function defines new primitive shapes. One of the following parameters are used as the first parameter: ELLIPSE, RECT, ARC, TRIANGLE, SPHERE, BOX, QUAD, LINE. The parameters for each of these different shapes are the same as their corresponding functions: ellipse(), rect(), arc(), triangle(), sphere(), box(), and line(). The first example above clarifies how this works.

If so, please resolve the rounded corners bug first #2648 then if the documentation needs to be updated to sync with the (fixed) functionality, post an issue to: https://github.com/processing/processing-docs/issues/

Thanks!

@JakubValtar

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Jul 26, 2014

Contributor

@alignedleft Yes, that's the paragraph I was talking about. Thanks for pointing it out. There probably won't be any changes to functionality. Just to be sure, I'll wait until my fix is accepted and then fill the docs issue.

Contributor

JakubValtar commented Jul 26, 2014

@alignedleft Yes, that's the paragraph I was talking about. Thanks for pointing it out. There probably won't be any changes to functionality. Just to be sure, I'll wait until my fix is accepted and then fill the docs issue.

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Jul 26, 2014

Member

Let's make sure we have the correct behavior first... For the most part, createShape(RECT, ...) should mirror what rect() does. The one difference would be if we're not honoring rectMode() (the same as we do with colorMode()), but someone should double-check on that.

Member

benfry commented Jul 26, 2014

Let's make sure we have the correct behavior first... For the most part, createShape(RECT, ...) should mirror what rect() does. The one difference would be if we're not honoring rectMode() (the same as we do with colorMode()), but someone should double-check on that.

@JakubValtar

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Jul 26, 2014

Contributor

There are three versions of rect:

rect(x1, y1, x2, y2);
rect(x1, y1, x2, y2, radius);
rect(x1, y1, x2, y2, tl, tr, br, bl);

The thing is that we can not mirror five parameter version because
createShape(RECT, x1, y1, x2, y2, radius) would have the same signature as
createShape(RECT, x1, y1, x2, y2, mode).

That leaves us with four and eight parameter versions:

createShape(RECT, x1, y1, x2, y2);
createShape(RECT, x1, y1, x2, y2, tl, tr, br, bl);

Plus two with extra mode parameter:

createShape(RECT, x1, y1, x2, y2, mode);
createShape(RECT, x1, y1, x2, y2, tl, tr, br, bl, mode);

These mirror rect, I checked yesterday.

The only place of confusion is that
createShape(RECT, x1, y1, x2, y2, mode) can be confused with
createShape(RECT, x1, y1, x2, y2, radius) and reference does not say a thing about it.

Contributor

JakubValtar commented Jul 26, 2014

There are three versions of rect:

rect(x1, y1, x2, y2);
rect(x1, y1, x2, y2, radius);
rect(x1, y1, x2, y2, tl, tr, br, bl);

The thing is that we can not mirror five parameter version because
createShape(RECT, x1, y1, x2, y2, radius) would have the same signature as
createShape(RECT, x1, y1, x2, y2, mode).

That leaves us with four and eight parameter versions:

createShape(RECT, x1, y1, x2, y2);
createShape(RECT, x1, y1, x2, y2, tl, tr, br, bl);

Plus two with extra mode parameter:

createShape(RECT, x1, y1, x2, y2, mode);
createShape(RECT, x1, y1, x2, y2, tl, tr, br, bl, mode);

These mirror rect, I checked yesterday.

The only place of confusion is that
createShape(RECT, x1, y1, x2, y2, mode) can be confused with
createShape(RECT, x1, y1, x2, y2, radius) and reference does not say a thing about it.

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Jul 26, 2014

Member

@codeanticode can't we just inherit the rectMode from the parent sketch here?

(The mode and radius versions of the function have different signatures since one is a float and the other an int, but it's a distinction without a difference because the radius will usually be passed in as an integer.)

Member

benfry commented Jul 26, 2014

@codeanticode can't we just inherit the rectMode from the parent sketch here?

(The mode and radius versions of the function have different signatures since one is a float and the other an int, but it's a distinction without a difference because the radius will usually be passed in as an integer.)

@clankill3r

This comment has been minimized.

Show comment
Hide comment
@clankill3r

clankill3r Jul 27, 2014

can't we just inherit the rectMode from the parent sketch here?

I think that would also fits processing style more.

clankill3r commented Jul 27, 2014

can't we just inherit the rectMode from the parent sketch here?

I think that would also fits processing style more.

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Jul 28, 2015

Member

Decision here is to drop the mode parameter and inherit from the parent sketch, the way that we do with other features like fill() and stroke().

Member

benfry commented Jul 28, 2015

Decision here is to drop the mode parameter and inherit from the parent sketch, the way that we do with other features like fill() and stroke().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment