Skip to content

shapeMode() new feature #3509

Closed
Closed

Description

@hellonearthis

Processing has a shapeMode() function that lets you set the draw position to be CENTER, CORNER or CORNERS This is missing from P5 and means that extra work is needed when defining a shape.

  • New feature request

Most appropriate sub-area of p5.js?

New feature details:

shapeMode() function
that lets you set the draw position to be.
shapeMode(CENTER) shapeMode(CORNER) shapeMode(CORNERS)

Activity

  1. sanketsingh24 commented on Feb 9, 2019

    @sanketsingh24
    Contributor

    Really cool feature 👍 Would like to work on this. Although I am not free this weekend, would implement the feature on Monday.

  2. changed the title [-]shameMode() new feature[/-] [+]shapeMode() new feature[/+] on Feb 9, 2019
  3. sanketsingh24 commented on Feb 25, 2019

    @sanketsingh24
    Contributor

    Hello, What I found out was there is no shape() function in p5, but the support for .OBJ files is via model(), while there is no native support for .SVG files, but can be added via image(), which has the same imagemode(). Well, I don't see the need for the shapemode() feature, but something on the lines of modelmode() can be implemented, but I don't know about the .SVG, and custom shapes, which has to be implemented first.@hellonearthis @stalgiag Can you please present your views on this?

  4. hellonearthis commented on Feb 25, 2019

    @hellonearthis
    ContributorAuthor

    I was asking about shapeMode() in relation to beginShape() used in making custom shapes.
    Even having access to it's width and height would help.
    SVG would be a different story.

  5. stalgiag commented on Feb 25, 2019

    @stalgiag
    Contributor

    Hi @sanketsingh24 I believe the requested feature is an equivalent to rectMode for custom shapes made with beginShape() in the 2D renderer. @hellonearthis I think that making this would present a number of challenges because there currently is not an equivalent to PShape in p5. See this discussion for an explanation of the challenges involved in creating this.

  6. hellonearthis commented on Feb 25, 2019

    @hellonearthis
    ContributorAuthor

    I think your over complexing it. Yes, it would be an equivalent of rectMode. It would not be an SVG related thing as far as I can tell. It would be an attribute of beginShare().
    Maybe I should have said it was beginShapeMode( CORNER || CORNERS || RADIUS || CENTER )

    I don't see an easy way to do it as a p5 custom shape doesn't built/record it's width or height as it's being constructed. So a sketch like this means the user has to do extra coding to build that data themselfs.

    Is there a way that shapeBegin() could be an object, like let my-shape = beginShape() so that things like my-shape.width my-shape.height be accessed and (off topic) have that shape drawn using another function like paint(my-shape,x,y). Sorry digressed, just knowing the width and height so CENTER would help rotating custom shapes.

  7. stalgiag commented on Feb 25, 2019

    @stalgiag
    Contributor

    I agree this is separate from SVG support, but the requested feature would suggest a p5.Shape class that stores and updates info about the bounds and mode so that it can shift drawing accordingly.

  8. sanketsingh24 commented on Feb 26, 2019

    @sanketsingh24
    Contributor

    Ok, so it should be only for custom shapes made by beginshape() ? I would start to work on this now.

  9. devashish1099 commented on Feb 24, 2020

    @devashish1099

    @stalgiag i would like to work on this issue

  10. stalgiag commented on Feb 25, 2020

    @stalgiag
    Contributor

    Hi @devashish1099 I am not sure if we have a consensus on this feature yet.

    I will add the discussion label to attract opinions on whether the community is in favor of adding a p5.Shape class.

  11. Alex23rodriguez commented on May 17, 2021

    @Alex23rodriguez

    Has there been any progress? I'm working on visualising some 3D shapes made out of cubes and it would be very nice if I could create a custom shape to eliminate the lines between the cubes.
    3

  12. moved this from Proposal to Out of Scope in p5.js 2.x 🌱🌳on Jun 18, 2024
  13. ksen0 commented on Apr 17, 2025

    @ksen0
    Member

    Closing this one as there have been a lot of changes in the area. We have p5.Geometry for 3D and na internal p5.Shape that could be considered to be made public, so if someone is interested to make a new issue about that, they are welcome to do so in the p5.js 2.x board!

  14. moved this from Out of Scope to Completed in p5.js 2.x 🌱🌳on Apr 17, 2025
  15. added this to the 2.0 milestone on Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions