Skip to content
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

feat(Superformula): add superformula #274

Merged
merged 5 commits into from
Nov 3, 2023
Merged

feat(Superformula): add superformula #274

merged 5 commits into from
Nov 3, 2023

Conversation

andretchen0
Copy link
Contributor

@andretchen0 andretchen0 commented Oct 30, 2023

Closes #270

  • Run pnpm run docs:dev and see /guide/shapes/superformula.html.
  • Run pnpm run playground and see /shapes/superformula.

NOTE: Uses the unmerged .gitignore from this PR.

@stackblitz
Copy link

stackblitz bot commented Oct 30, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link

netlify bot commented Oct 30, 2023

Deploy Preview for cientos-tresjs ready!

Name Link
🔨 Latest commit d6cfcbe
🔍 Latest deploy log https://app.netlify.com/sites/cientos-tresjs/deploys/65441373f3c7790008c9bcd8
😎 Deploy Preview https://deploy-preview-274--cientos-tresjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@andretchen0 andretchen0 marked this pull request as ready for review October 30, 2023 05:30
/**
* B's first exponent
*/
expB1?: number
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andretchen0 looks amazing, I think I haven't seen this since university haha. When animated looks mesmerizing.

Wonder if this is the best way we can over the props:

The exponents are limited to 3 or to "N"? Could the user pass them as arrays?

Copy link
Contributor Author

@andretchen0 andretchen0 Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andretchen0 looks amazing, I think I haven't seen this since university haha. When animated looks mesmerizing.

Wonder if this is the best way we can over the props:

The exponents are limited to 3 or to "N"?

They are limited to 3. (The 3d plot is the product of 2 2d plots. Each 2d plot has 3 exponents.)

Could the user pass them as arrays?

Just to be clear: Do you want to offer both :args and :exp-a1, etc? Or just :args?

If we want to offer :args, I guess I'd prefer to allow the user to pass an :args array, in addition to keywords.

Reasoning

All the args are optional and there are currently 11 of them. In the case of positional args, that leads to calls like:

<Superformula :args="[128, 128, 4, undefined, undefined, undefined, 3, undefined, undefined, 1]" />

The editor's auto-complete helps out, but it still seems kind of hairy. (I was also thinking of offering phiStart, phiLength, thetaStart, thetaLength, as these make it possible to create some shapes that are impossible with the superformula alone. So that's 4 extra args, or 15 in total.)

I see that <Sphere /> works with :args but not keyword arguments. But <Sphere /> only really needs 3 or fewer of those - the last 4 args are for drawing partial spheres or offsetting.

In contrast, <Superformula /> really needs 3+ arguments, often more, in order to specify the shapes the user wants.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there @andretchen0 , normally :args is reserved for the class constructor params. I was thinking more of:

<Superformula :exp-b="[b1, b2, b3]" />

Copy link
Contributor Author

@andretchen0 andretchen0 Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Superformula :exp-b="[b1, b2, b3]" />

Ah, I see. Done.

Copy link
Member

@alvarosabu alvarosabu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing job @andretchen0 Thanks for grouping the props, lets merge this

@alvarosabu alvarosabu merged commit 19130b4 into main Nov 3, 2023
6 checks passed
@andretchen0 andretchen0 deleted the feat/superformula branch November 3, 2023 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New shape: Superformula
2 participants