-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Option complexity, some changes to animations, MathAnimations, change…
…s to color option, and chroma text for TextWidget rainbow.
- Loading branch information
1 parent
59d1de4
commit b0dbca6
Showing
26 changed files
with
335 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
...va/com/tanishisherewith/dynamichud/helpers/animationhelper/animations/MathAnimations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package com.tanishisherewith.dynamichud.helpers.animationhelper.animations; | ||
|
||
import net.minecraft.util.math.Vec2f; | ||
import net.minecraft.util.math.random.Random; | ||
|
||
public class MathAnimations { | ||
// SHAKE: Random offset animation with smooth decay | ||
public static float shake(float intensity, float frequency, float decay) { | ||
long time = System.currentTimeMillis(); | ||
return (float) (Math.sin(time * frequency) * | ||
Math.exp(-decay * time) * intensity); | ||
} | ||
|
||
// 2D Shake with different X/Y frequencies | ||
public static Vec2f shake2D(float intensity, float freqX, float freqY) { | ||
return new Vec2f( | ||
(float) Math.sin(System.currentTimeMillis() * freqX) * intensity, | ||
(float) Math.cos(System.currentTimeMillis() * freqY) * intensity | ||
); | ||
} | ||
|
||
// FLICKER: Random flashing effect | ||
public static float flicker(float min, float max, float chance) { | ||
Random rand = Random.create(); | ||
return rand.nextFloat() < chance ? | ||
min + (max - min) * rand.nextFloat() : | ||
max; | ||
} | ||
|
||
// CIRCULAR MOTION: Perfect for rotation/orbital animations | ||
public static Vec2f circularMotion(float radius, float speed, float phase) { | ||
double angle = Math.toRadians((System.currentTimeMillis() * speed) % 360 + phase); | ||
return new Vec2f( | ||
(float) (Math.cos(angle) * radius), | ||
(float) (Math.sin(angle) * radius) | ||
); | ||
} | ||
|
||
// SAWTOOTH WAVE: Linear rise with sudden drop | ||
public static float sawtooth(float period, float min, float max) { | ||
float phase = (System.currentTimeMillis() % period) / period; | ||
return min + (max - min) * phase; | ||
} | ||
|
||
// TRIANGULAR WAVE: Linear rise and fall | ||
public static float triangleWave(float period, float min, float max) { | ||
float halfPeriod = period / 2; | ||
float phase = (System.currentTimeMillis() % period); | ||
float value = phase < halfPeriod ? | ||
(phase / halfPeriod) : | ||
2 - (phase / halfPeriod); | ||
return min + (max - min) * value; | ||
} | ||
|
||
// BOUNCE: Simulates physical bouncing | ||
public static float bounce(float dropHeight, float gravity, float dampening) { | ||
float t = System.currentTimeMillis() / 1000f; | ||
return (float) (dropHeight * Math.abs(Math.sin(t * Math.sqrt(gravity))) * | ||
Math.exp(-dampening * t)); | ||
} | ||
|
||
// PULSE: Smooth heartbeat-like effect | ||
public static float pulse1(float base, float amplitude, float frequency) { | ||
return (float) (base + amplitude * | ||
(0.5 + 0.5 * Math.sin(System.currentTimeMillis() * frequency))); | ||
} | ||
|
||
// SPIRAL: Circular motion with expanding radius | ||
public static Vec2f spiral(float baseRadius, float expansionRate, float speed) { | ||
float t = System.currentTimeMillis() / 1000f; | ||
return new Vec2f( | ||
(float) ((baseRadius + expansionRate * t) * Math.cos(t * speed)), | ||
(float) ((baseRadius + expansionRate * t) * Math.sin(t * speed)) | ||
); | ||
} | ||
|
||
// Continuous pulsating effect using sine wave | ||
public static float pulse2(float speed, float min, float max) { | ||
return (float) ((Math.sin(System.currentTimeMillis() * speed) + 1) / 2 * (max - min) + min); | ||
} | ||
|
||
// Linear interpolation between values over time | ||
public static float lerp(float start, float end, long startTime, float duration) { | ||
float progress = (System.currentTimeMillis() - startTime) / duration; | ||
progress = Math.min(1, Math.max(0, progress)); // Clamp 0-1 | ||
return start + (end - start) * progress; | ||
} | ||
|
||
// Bouncing animation using quadratic ease-out | ||
public static float bounce(float start, float end, long startTime, float duration) { | ||
float time = System.currentTimeMillis() - startTime; | ||
time /= duration; | ||
return end * (1 - (time - 1) * (time - 1)) + start; | ||
} | ||
|
||
// Continuous rotation using modulo | ||
public static float continuousRotation(float speed) { | ||
return (System.currentTimeMillis() % (360_000 / speed)) * (speed / 1000); | ||
} | ||
|
||
// Elastic wobble effect | ||
public static float elasticWobble(float speed, float magnitude) { | ||
return (float) (Math.sin(System.currentTimeMillis() * speed) * | ||
Math.exp(-0.001 * System.currentTimeMillis()) * magnitude); | ||
} | ||
|
||
// Infinite rotation | ||
public static float infiniteRotation(float speed) { | ||
return (System.currentTimeMillis() % (360_000 / speed)) * (speed / 1000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.