Skip to content

Commit

Permalink
Jeddic#6 Allow direct passing of floats and add to size influencer ja…
Browse files Browse the repository at this point in the history
…vadoc
  • Loading branch information
richardTingle committed Dec 18, 2021
1 parent 3287009 commit 1b30a24
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
* Size Module
* The size module controls the particle size over time
*
* To create a size inflencer that linearly changes the particle size from 0.3 to 0.1 over its lifetime create like:
* <pre>{@code
* ValueType sizeOverTime = new ValueType(Curve.builder().anchorPoint(0f, 0.03f).anchorPoint(1f, 0.01f).end());
* SizeInfluencer sizeInfluencer = new SizeInfluencer();
* sizeInfluencer.setSizeOverTime(sizeOverTime);
* }</pre>
*
* @author t0neg0d
* @author Jeddic
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ public CurveBuilderAtControlPoint1 controlPoint1( Vector2f nextControlPoint ){
return new CurveBuilderAtControlPoint1(curveBeingBuilt, controlPointIn, currentAnchor, nextControlPoint);
}

/**
* Produces a straight line between 2 anchor points
* @param x the x of the next anchor point
* @param y the y of the next anchor point
* @return a CurveBuilderAtAnchor a part of the curve builder system
*/
public CurveBuilderAtAnchor anchorPoint(float x, float y){
return anchorPoint(new Vector2f(x,y));
}

/**
* Produces a straight line between 2 anchor points
* @param nextAnchor the next anchor point
Expand All @@ -35,7 +45,7 @@ public CurveBuilderAtAnchor anchorPoint(Vector2f nextAnchor ){
//simulate a straight line using a Bézier curve
Vector2f midOne = currentAnchor.mult(2f/3).add(nextAnchor.mult(1f/3));
Vector2f midTwo = currentAnchor.mult(1f/3).add(nextAnchor.mult(2f/3));
return controlPoint1(midOne).controlPoint2(midTwo).nextAnchor(nextAnchor);
return controlPoint1(midOne).controlPoint2(midTwo).anchorPoint(nextAnchor);
}

public Curve end(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ public class CurveBuilderStart{

Curve curveBeingBuilt = new Curve();

public CurveBuilderAtAnchor anchorPoint(float x, float y){
return anchorPoint(new Vector2f(x,y));
}

/**
* Adds the first anchor point, where the line will start
* @return CurveBuilderAtAnchor a part of the curve builder system
Expand Down

0 comments on commit 1b30a24

Please sign in to comment.