[Patchanim-commit] SF.net SVN: patchanim: [196] trunk/patchanim/src/com/mebigfatguy/patchanim
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-02-18 02:31:39
|
Revision: 196
http://patchanim.svn.sourceforge.net/patchanim/?rev=196&view=rev
Author: dbrosius
Date: 2008-02-17 18:31:45 -0800 (Sun, 17 Feb 2008)
Log Message:
-----------
fix cycle so that the last frame blends into the first
Modified Paths:
--------------
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java
trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java 2008-02-16 04:35:19 UTC (rev 195)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java 2008-02-18 02:31:45 UTC (rev 196)
@@ -90,8 +90,8 @@
for (int p = 0; p < lastPatch; p++) {
CombinedPatch startPatch = patches.get(p);
CombinedPatch endPatch = patches.get(p+1);
- for (int t = 0; t < tweenCount; t++) {
- CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)tweenCount);
+ for (int t = 0; t < tweenCount + 1; t++) {
+ CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1));
PatchGenerator.recalcCombinedImage(tweenPatch, image, oob);
long now = System.currentTimeMillis();
long sleepTime = 100 - (now - lastRedraw);
@@ -102,15 +102,16 @@
}
}
- if (type == AnimationType.None)
- return;
-
- if (type == AnimationType.Wave) {
- for (int p = lastPatch; p > 0; p--) {
- CombinedPatch startPatch = patches.get(p-1);
- CombinedPatch endPatch = patches.get(p);
- for (int t = tweenCount - 1; t >= 0; t--) {
- CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)tweenCount);
+ switch (type) {
+ case None: {
+ return;
+ }
+
+ case Cycle: {
+ CombinedPatch startPatch = patches.get(lastPatch);
+ CombinedPatch endPatch = patches.get(0);
+ for (int t = 0; t <= tweenCount + 1; t++) {
+ CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1));
PatchGenerator.recalcCombinedImage(tweenPatch, image, oob);
long now = System.currentTimeMillis();
long sleepTime = 100 - (now - lastRedraw);
@@ -120,6 +121,25 @@
lastRedraw = now;
}
}
+ break;
+
+ case Wave: {
+ for (int p = lastPatch; p > 0; p--) {
+ CombinedPatch startPatch = patches.get(p-1);
+ CombinedPatch endPatch = patches.get(p);
+ for (int t = tweenCount + 1; t > 0; t--) {
+ CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1));
+ PatchGenerator.recalcCombinedImage(tweenPatch, image, oob);
+ long now = System.currentTimeMillis();
+ long sleepTime = 100 - (now - lastRedraw);
+ if (sleepTime > 0)
+ Thread.sleep(sleepTime);
+ testPanel.redraw();
+ lastRedraw = now;
+ }
+ }
+ }
+ break;
}
}
} catch (InterruptedException ie) {
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-02-16 04:35:19 UTC (rev 195)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-02-18 02:31:45 UTC (rev 196)
@@ -116,25 +116,40 @@
writeSingleFile(image, imageIndex++, loc, baseName, type);
}
}
+
+ switch (atype) {
+ case None: {
+ CombinedPatch patch = patches.get(lastPatch);
+ PatchGenerator.recalcCombinedImage(patch, image, oob);
+ writeSingleFile(image, imageIndex++, loc, baseName, type);
+ if (atype == AnimationType.None)
+ return;
+ }
+ break;
- if ((atype == AnimationType.None) || (atype == AnimationType.Cycle)) {
- CombinedPatch patch = patches.get(lastPatch);
- PatchGenerator.recalcCombinedImage(patch, image, oob);
- writeSingleFile(image, imageIndex++, loc, baseName, type);
- if (atype == AnimationType.None)
- return;
- }
-
- if (atype == AnimationType.Wave) {
- for (int p = lastPatch; p > 0; p--) {
- CombinedPatch startPatch = patches.get(p-1);
- CombinedPatch endPatch = patches.get(p);
- for (int t = tweenCount + 1; t > 0; t--) {
+ case Cycle: {
+ CombinedPatch startPatch = patches.get(lastPatch);
+ CombinedPatch endPatch = patches.get(0);
+ for (int t = 0; t < tweenCount + 1; t++) {
CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1));
PatchGenerator.recalcCombinedImage(tweenPatch, image, oob);
writeSingleFile(image, imageIndex++, loc, baseName, type);
}
}
+ break;
+
+ case Wave: {
+ for (int p = lastPatch; p > 0; p--) {
+ CombinedPatch startPatch = patches.get(p-1);
+ CombinedPatch endPatch = patches.get(p);
+ for (int t = tweenCount + 1; t > 0; t--) {
+ CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1));
+ PatchGenerator.recalcCombinedImage(tweenPatch, image, oob);
+ writeSingleFile(image, imageIndex++, loc, baseName, type);
+ }
+ }
+ }
+ break;
}
}
} finally {
@@ -188,10 +203,19 @@
int numPatches = document.getPatches().size();
int total = (numPatches - 1) * document.getTweenCount() + (numPatches - 1);
- if (document.getAnimationType() == AnimationType.Wave)
- total = total * 2;
- else
- total++;
+ switch (document.getAnimationType()) {
+ case None:
+ total++;
+ break;
+
+ case Cycle:
+ total += document.getTweenCount() + 1;
+ break;
+
+ case Wave:
+ total = total * 2;
+ break;
+ }
return total;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|