Skip to content

Commit

Permalink
optimize tween computations
Browse files Browse the repository at this point in the history
  • Loading branch information
foo123 committed Dec 8, 2022
1 parent 1f19041 commit f20893a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions build/Geometrize.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* Geometrize
* computational geometry and rendering library for JavaScript
*
* @version 0.6.0 (2022-12-08 19:02:30)
* @version 0.6.0 (2022-12-08 22:04:06)
* https://github.com/foo123/Geometrize
*
**//**
* Geometrize
* computational geometry and rendering library for JavaScript
*
* @version 0.6.0 (2022-12-08 19:02:30)
* @version 0.6.0 (2022-12-08 22:04:06)
* https://github.com/foo123/Geometrize
*
**/
Expand Down Expand Up @@ -4084,6 +4084,8 @@ function first_frame(tween)
cos = stdMath.cos(angle);
sin = stdMath.sin(angle);
}
tx += orx - cos*orx + sin*ory;
ty += ory - cos*ory - sin*orx;
for (i=0; i<n; ++i)
{
ai = as[i];
Expand All @@ -4094,8 +4096,8 @@ function first_frame(tween)
x = sx*(aij.x - osx) + osx;
y = sy*(aij.y - osy) + osy;
s[j] = {
x: cos*x - sin*y + orx - cos*orx + sin*ory + tx,
y: sin*x + cos*y + ory - cos*ory - sin*orx + ty
x: cos*x - sin*y + tx,
y: sin*x + cos*y + ty
};
}
cs[i] = s;
Expand Down Expand Up @@ -4165,6 +4167,8 @@ function next_frame(tween)
cos = stdMath.cos(angle);
sin = stdMath.sin(angle);
}
tx += orx - cos*orx + sin*ory;
ty += ory - cos*ory - sin*orx;
for (i=0; i<n; ++i)
{
ai = as[i];
Expand All @@ -4177,8 +4181,8 @@ function next_frame(tween)
x = sx*(aij.x + t*(bij.x - aij.x) - osx) + osx;
y = sy*(aij.y + t*(bij.y - aij.y) - osy) + osy;
s[j] = {
x: cos*x - sin*y + orx - cos*orx + sin*ory + tx,
y: sin*x + cos*y + ory - cos*ory - sin*orx + ty
x: cos*x - sin*y + tx,
y: sin*x + cos*y + ty
};
}
cs[i] = s;
Expand Down
4 changes: 2 additions & 2 deletions build/Geometrize.min.js

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions src/Tween.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ function first_frame(tween)
cos = stdMath.cos(angle);
sin = stdMath.sin(angle);
}
tx += orx - cos*orx + sin*ory;
ty += ory - cos*ory - sin*orx;
for (i=0; i<n; ++i)
{
ai = as[i];
Expand All @@ -263,8 +265,8 @@ function first_frame(tween)
x = sx*(aij.x - osx) + osx;
y = sy*(aij.y - osy) + osy;
s[j] = {
x: cos*x - sin*y + orx - cos*orx + sin*ory + tx,
y: sin*x + cos*y + ory - cos*ory - sin*orx + ty
x: cos*x - sin*y + tx,
y: sin*x + cos*y + ty
};
}
cs[i] = s;
Expand Down Expand Up @@ -334,6 +336,8 @@ function next_frame(tween)
cos = stdMath.cos(angle);
sin = stdMath.sin(angle);
}
tx += orx - cos*orx + sin*ory;
ty += ory - cos*ory - sin*orx;
for (i=0; i<n; ++i)
{
ai = as[i];
Expand All @@ -346,8 +350,8 @@ function next_frame(tween)
x = sx*(aij.x + t*(bij.x - aij.x) - osx) + osx;
y = sy*(aij.y + t*(bij.y - aij.y) - osy) + osy;
s[j] = {
x: cos*x - sin*y + orx - cos*orx + sin*ory + tx,
y: sin*x + cos*y + ory - cos*ory - sin*orx + ty
x: cos*x - sin*y + tx,
y: sin*x + cos*y + ty
};
}
cs[i] = s;
Expand Down

0 comments on commit f20893a

Please sign in to comment.