mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-07 19:26:54 +08:00
Clean up.
This commit is contained in:
parent
42fa637508
commit
b8da5a1d44
@ -14,6 +14,17 @@ public class JitterEffect implements VertexEffect {
|
|||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void begin (Skeleton skeleton) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void transform (Vector2 vertex) {
|
||||||
|
vertex.x += MathUtils.randomTriangular(-x, y);
|
||||||
|
vertex.y += MathUtils.randomTriangular(-x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void end () {
|
||||||
|
}
|
||||||
|
|
||||||
public void setJitter (float x, float y) {
|
public void setJitter (float x, float y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@ -26,15 +37,4 @@ public class JitterEffect implements VertexEffect {
|
|||||||
public void setJitterY (float y) {
|
public void setJitterY (float y) {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void begin (Skeleton skeleton) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void transform (Vector2 vertex) {
|
|
||||||
vertex.x += MathUtils.randomTriangular(-x, y);
|
|
||||||
vertex.y += MathUtils.randomTriangular(-x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void end () {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,26 @@ public class SwirlEffect implements VertexEffect {
|
|||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void begin (Skeleton skeleton) {
|
||||||
|
worldX = skeleton.getX() + centerX;
|
||||||
|
worldY = skeleton.getY() + centerY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void transform (Vector2 vertex) {
|
||||||
|
float x = vertex.x - worldX;
|
||||||
|
float y = vertex.y - worldY;
|
||||||
|
float dist = (float)Math.sqrt(x * x + y * y);
|
||||||
|
if (dist < radius) {
|
||||||
|
float theta = interpolation.apply(0, angle, (radius - dist) / radius);
|
||||||
|
float cos = SpineUtils.cos(theta), sin = SpineUtils.sin(theta);
|
||||||
|
vertex.x = cos * x - sin * y + worldX;
|
||||||
|
vertex.y = sin * x + cos * y + worldY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void end () {
|
||||||
|
}
|
||||||
|
|
||||||
public void setRadius (float radius) {
|
public void setRadius (float radius) {
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
@ -38,23 +58,11 @@ public class SwirlEffect implements VertexEffect {
|
|||||||
this.angle = degrees * MathUtils.degRad;
|
this.angle = degrees * MathUtils.degRad;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void begin (Skeleton skeleton) {
|
public Interpolation getInterpolation () {
|
||||||
worldX = skeleton.getX() + centerX;
|
return interpolation;
|
||||||
worldY = skeleton.getY() + centerY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transform (Vector2 vertex) {
|
public void setInterpolation (Interpolation interpolation) {
|
||||||
float x = vertex.x - worldX;
|
this.interpolation = interpolation;
|
||||||
float y = vertex.y - worldY;
|
|
||||||
float dist = (float)Math.sqrt(x * x + y * y);
|
|
||||||
if (dist < radius) {
|
|
||||||
float theta = interpolation.apply(0, angle, (radius - dist) / radius);
|
|
||||||
float cos = SpineUtils.cos(theta), sin = SpineUtils.sin(theta);
|
|
||||||
vertex.x = cos * x - sin * y + worldX;
|
|
||||||
vertex.y = sin * x + cos * y + worldY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void end () {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user