From 1b30a2485d2f02164ced36068d55e0c49916106d Mon Sep 17 00:00:00 2001 From: Richard Tingle <6330028+richardTingle@users.noreply.github.com> Date: Sat, 18 Dec 2021 15:33:25 +0000 Subject: [PATCH] #6 Allow direct passing of floats and add to size influencer javadoc --- .../epaga/particles/influencers/SizeInfluencer.java | 7 +++++++ .../curvebuilder/CurveBuilderAtAnchor.java | 12 +++++++++++- .../valuetypes/curvebuilder/CurveBuilderStart.java | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/epaga/particles/influencers/SizeInfluencer.java b/src/main/java/com/epaga/particles/influencers/SizeInfluencer.java index 4f71ee4..ebff8b5 100644 --- a/src/main/java/com/epaga/particles/influencers/SizeInfluencer.java +++ b/src/main/java/com/epaga/particles/influencers/SizeInfluencer.java @@ -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: + *
{@code
+ *         ValueType sizeOverTime = new ValueType(Curve.builder().anchorPoint(0f, 0.03f).anchorPoint(1f, 0.01f).end());
+ *         SizeInfluencer sizeInfluencer = new SizeInfluencer();
+ *         sizeInfluencer.setSizeOverTime(sizeOverTime);
+ * }
+ * * @author t0neg0d * @author Jeddic */ diff --git a/src/main/java/com/epaga/particles/valuetypes/curvebuilder/CurveBuilderAtAnchor.java b/src/main/java/com/epaga/particles/valuetypes/curvebuilder/CurveBuilderAtAnchor.java index 80aba70..999ff35 100644 --- a/src/main/java/com/epaga/particles/valuetypes/curvebuilder/CurveBuilderAtAnchor.java +++ b/src/main/java/com/epaga/particles/valuetypes/curvebuilder/CurveBuilderAtAnchor.java @@ -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 @@ -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(){ diff --git a/src/main/java/com/epaga/particles/valuetypes/curvebuilder/CurveBuilderStart.java b/src/main/java/com/epaga/particles/valuetypes/curvebuilder/CurveBuilderStart.java index eec04db..8e45793 100644 --- a/src/main/java/com/epaga/particles/valuetypes/curvebuilder/CurveBuilderStart.java +++ b/src/main/java/com/epaga/particles/valuetypes/curvebuilder/CurveBuilderStart.java @@ -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