[Patchanim-commit] SF.net SVN: patchanim:[255] trunk/patchanim/src/com/mebigfatguy/patchanim/ surfa
Brought to you by:
dbrosius
From: <dbr...@us...> - 2008-12-25 18:35:55
|
Revision: 255 http://patchanim.svn.sourceforge.net/patchanim/?rev=255&view=rev Author: dbrosius Date: 2008-12-25 18:35:51 +0000 (Thu, 25 Dec 2008) Log Message: ----------- put in a bogus algo, till we fix other stuff Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java 2008-12-25 18:16:48 UTC (rev 254) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java 2008-12-25 18:35:51 UTC (rev 255) @@ -27,7 +27,7 @@ public class PatchCoords implements Serializable, Cloneable { private static final long serialVersionUID = -4052789167154764908L; - private int order; + private final int order; private Coordinate[][] coords; public static PatchCoords buildRandomPatch(int patchOrder) { @@ -84,16 +84,37 @@ public static PatchCoords tween(PatchCoords startCoords, PatchCoords endCoords, TweenStyle tweenStyle, double frac) { PatchCoords tweenCoords = new PatchCoords(startCoords.getOrder()); - 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) * frac); - Coordinate tweenC = new Coordinate(startC.getX(), endC.getY(), tweenColor); - tweenCoords.setCoordinate(x, y, tweenC); - } + switch (tweenStyle) { + case Linear: + /* this only works if the lattice is fixed */ + 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) * frac); + Coordinate tweenC = new Coordinate(startC.getX(), endC.getY(), 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; } + return tweenCoords; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |