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

Add builder to the Curve class #6

Open
richardTingle opened this issue Dec 18, 2021 · 0 comments
Open

Add builder to the Curve class #6

richardTingle opened this issue Dec 18, 2021 · 0 comments

Comments

@richardTingle
Copy link
Contributor

richardTingle commented Dec 18, 2021

Having thought about why I found the way adding control points to curves confusing I'd like to add a builder that would be used like this:

    Curve curve = Curve.builder()
            .anchorPoint(new Vector2f(0,0))
            .anchorPoint(new Vector2f(0.5f,0.5f))
            .controlPoint1(new Vector2f(0.6f,0.5f))
            .controlPoint2(new Vector2f(0.8f,2f))
            .anchorPoint(new Vector2f(1,2f))
            .build();

This example produces a straight line from (0,0) -> (0.5,0.5), then a cubic Besier curves between (0.5,0.5) -> (1,2) with control points (0.6,0.5) and (0.8,2).

The builder statically prevents end being called when not at an anchor, or controlPoint1 or controlPoint2 or nextAnchor being called at the wrong time

richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 18, 2021
…fied as a series of anchor and control points
richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 18, 2021
richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 18, 2021
richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 18, 2021
richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 18, 2021
richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 18, 2021
richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 18, 2021
richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 21, 2021
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

No branches or pull requests

1 participant