Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions core/src/main/java/com/qmdeve/liquidglass/util/LiquidTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,29 @@ private float[] getLiquidScale() {
velocityTracker.computeCurrentVelocity(1);
float velocityX = velocityTracker.getXVelocity();
float velocityY = velocityTracker.getYVelocity();
float velocity = (float)Math.sqrt(velocityX * velocityX + velocityY * velocityY);

// Calculate deformation separately for X and Y directions
// Stretch along movement direction, compress perpendicular to it
float absVx = Math.abs(velocityX);
float absVy = Math.abs(velocityY);

// Deformation intensity factor, adjust this value to control the degree of deformation
float stretchFactor = 0.5f;

float scaleX, scaleY;
if (absVx > absVy) {
// Horizontal movement dominant: stretch X axis, compress Y axis
scaleX = 1f + absVx * stretchFactor;
scaleY = 1f - absVx * stretchFactor * 0.5f;
} else {
// Vertical movement dominant: stretch Y axis, compress X axis
scaleX = 1f - absVy * stretchFactor * 0.5f;
scaleY = 1f + absVy * stretchFactor;
}

return new float[] {
Math.clamp(1f + velocity * 0.5f, 0.6f, 1.4f),
Math.clamp(1f - velocity * 0.5f, 0.6f, 1.4f)
Math.clamp(scaleX, 0.6f, 1.4f),
Math.clamp(scaleY, 0.6f, 1.4f)
};
}

Expand Down