[Patchanim-commit] SF.net SVN: patchanim:[260] trunk/patchanim/src/com/mebigfatguy/patchanim
Brought to you by:
dbrosius
From: <dbr...@us...> - 2008-12-26 00:03:12
|
Revision: 260 http://patchanim.svn.sourceforge.net/patchanim/?rev=260&view=rev Author: dbrosius Date: 2008-12-26 00:03:08 +0000 (Fri, 26 Dec 2008) Log Message: ----------- switch TweenStyle to a set of transformation functions on the 0->1 tween fraction Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/TweenStyle.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/TweenStyle.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/TweenStyle.java 2008-12-25 23:38:58 UTC (rev 259) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/TweenStyle.java 2008-12-26 00:03:08 UTC (rev 260) @@ -18,6 +18,7 @@ */ package com.mebigfatguy.patchanim; +import java.awt.Point; import java.util.ResourceBundle; import com.mebigfatguy.patchanim.main.PatchAnimBundle; @@ -25,15 +26,34 @@ /** * denotes the algorithm to use to tween two patches * <ul> - * <li><b>Linear</b> Control points are tweened linearly</li> - * <li><b>Radial</b> Control points are tweened radially</li> + * <li><b>Linear</b> Control points are tweened linearly from start to finish</li> + * <li><b>Accelerating</b> Control points are tweened accelerating from start to finish</li> + * <li><b>Decelerating</b> Control points are tweened decelerating from start to finish</li> + * <li><b>EaseInEaseOut</b> Control points are tweened eased in from start, then eased out to finish</li> + * <li><b>Accelerating</b> Control points are tweened accelerating in from start and then accelerated out to finish</li> + * <li><b>Accelerating</b> Control points are tweened waved from start to finish</li> * </ul> */ public enum TweenStyle { - Linear, - Radial; + Linear(new Point(0, 0), new Point(0, 0), new Point(100, 100), new Point(100, 100)), + Accelerating(new Point(0, 0), new Point(100, 0), new Point(100, 100), new Point(100, 100)), + Decelerating(new Point(0, 0), new Point(0, 100), new Point(100, 100), new Point(100, 100)), + EaseInEaseOut(new Point(0, 0), new Point(50, 0), new Point(50, 100), new Point(100, 100)), + AccelerateInAccelerateOut(new Point(0, 0), new Point(0, 50), new Point(100, 50), new Point(100, 100)), + Wave(new Point(0, 0), new Point(0, 200), new Point(100, -200), new Point(100, 100)); private static final String TWEEN = "tweenstyle."; + + private Point[] points; + + private TweenStyle(Point... pts) { + points = pts; + } + + public double transform(double frac) { + return frac; + } + /** * returns the localized value of the enum * @return the localized display value Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java 2008-12-25 23:38:58 UTC (rev 259) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java 2008-12-26 00:03:08 UTC (rev 260) @@ -26,6 +26,7 @@ import java.awt.event.FocusListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.EnumSet; import java.util.ResourceBundle; import javax.swing.BorderFactory; @@ -137,8 +138,8 @@ add(Box.createVerticalStrut(5)); { tweenStyleLabel = new JLabel(rb.getString(PatchAnimBundle.TWEENSTYLE)); - tweenStyleCB = new JComboBox(new Object[] { TweenStyle.Linear, - TweenStyle.Radial }); + EnumSet<TweenStyle> ts = EnumSet.<TweenStyle>allOf(TweenStyle.class); + tweenStyleCB = new JComboBox(ts.toArray(new TweenStyle[ts.size()])); tweenStyleCB.setToolTipText(rb.getString(PatchAnimBundle.TWEENSTYLE_TT)); outOfBoundsLabel.setLabelFor(tweenStyleCB); JPanel p = Utils.createFormPanel(tweenStyleLabel, tweenStyleCB); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-12-25 23:38:58 UTC (rev 259) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-12-26 00:03:08 UTC (rev 260) @@ -66,7 +66,11 @@ patchanim.tweenstyle = Tween Style patchanim.tooltip.tweenstyle = The algorithm used to transition from one patch to another patchanim.tweenstyle.linear = Linear -patchanim.tweenstyle.radial = Radial +patchanim.tweenstyle.accelerating = Accelerating +patchanim.tweenstyle.decelerating = Decelerating +patchanim.tweenstyle.easeineaseout = Ease In/Ease Out +patchanim.tweenstyle.accelerateinaccelerateout = Accelerate In/Accelerate Out +patchanim.tweenstyle.wave = Wave patchanim.test = Test patchanim.tooltip.test = Test the animation using the export settings patchanim.stop = Stop Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java 2008-12-25 23:38:58 UTC (rev 259) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java 2008-12-26 00:03:08 UTC (rev 260) @@ -84,38 +84,15 @@ public static PatchCoords tween(PatchCoords startCoords, PatchCoords endCoords, TweenStyle tweenStyle, double frac) { PatchCoords tweenCoords = new PatchCoords(startCoords.getOrder()); - switch (tweenStyle) { - case Linear: - for (int x = 0; x < tweenCoords.order; x++) { - for (int y = 0; y < tweenCoords.order; y++) { - Coordinate startC = startCoords.getCoordinate(x,y); - Coordinate endC = endCoords.getCoordinate(x,y); - double startX = startC.getX(); - double startY = startC.getY(); - double startColor = startC.getColor(); - double tweenX = (startX + (endC.getX() - startX) * frac); - double tweenY = (startY + (endC.getY() - startY) * frac); - int tweenColor = (int)(startColor + (endC.getColor() - startColor) * frac); - Coordinate tweenC = new Coordinate(tweenX, tweenY, tweenColor); - tweenCoords.setCoordinate(x, y, tweenC); - } - } - break; - - case Radial: - /* this is completely bogus right now, just to fool 'em, till we fix stuff elsewhere */ - for (int x = 0; x < tweenCoords.order; x++) { - for (int y = 0; y < tweenCoords.order; y++) { - Coordinate startC = startCoords.getCoordinate(x,y); - Coordinate endC = endCoords.getCoordinate(x,y); - double[] startVector = new double[] { startC.getX(), startC.getY(), startC.getColor() }; - double[] endVector = new double[] { endC.getX(), endC.getY(), endC.getColor() }; - double ran = Math.random(); - Coordinate tweenC = new Coordinate(startVector[0], endVector[1], startVector[2] * ran + endVector[2] * (1 - ran)); - tweenCoords.setCoordinate(x, y, tweenC); - } - } - break; + for (int x = 0; x < tweenCoords.order; x++) { + for (int y = 0; y < tweenCoords.order; y++) { + Coordinate startC = startCoords.getCoordinate(x,y); + Coordinate endC = endCoords.getCoordinate(x,y); + double startColor = startC.getColor(); + int tweenColor = (int)(startColor + (endC.getColor() - startColor) * tweenStyle.transform(frac)); + Coordinate tweenC = new Coordinate(startC.getX(), startC.getY(), tweenColor); + tweenCoords.setCoordinate(x, y, tweenC); + } } return tweenCoords; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |