Permalink
Browse files

New frames take on the duration of the current frame, display will sc…

…ale to different LED sizes correctly.
  • Loading branch information...
1 parent b0a5d32 commit 4e2993cc2a2692feb635074a683c2b5b876ba3a3 @cibomahto cibomahto committed Dec 15, 2010
Showing with 20 additions and 14 deletions.
  1. +6 −6 AnimationFrame.pde
  2. +14 −8 PeggyDraw2.pde
View
12 AnimationFrame.pde
@@ -7,13 +7,11 @@ class AnimationFrames
protected int width;
protected int height;
- int defaultDuration;
- AnimationFrames(int width, int height, int defaultDuration)
+ AnimationFrames(int width, int height)
{
this.width = width;
this.height = height;
- this.defaultDuration = defaultDuration;
frames = new ArrayList();
addFrame(0);
@@ -48,7 +46,7 @@ class AnimationFrames
void addFrame(int position) {
// TODO: do we need to check that the position is in range?
- frames.add(position, new AnimationFrame(width, height, defaultDuration));
+ frames.add(position, new AnimationFrame(width, height));
current = position;
}
@@ -75,6 +73,8 @@ class AnimationFrame
int height;
int duration;
int frameData[];
+
+ int defaultDuration = 100;
AnimationFrame(AnimationFrame ref) {
width = ref.width;
@@ -88,10 +88,10 @@ class AnimationFrame
}
}
- AnimationFrame(int width, int height, int duration) {
+ AnimationFrame(int width, int height) {
this.width = width;
this.height = height;
- this.duration = duration;
+ this.duration = defaultDuration;
frameData = new int[height*width];
preset(0);
View
22 PeggyDraw2.pde
@@ -2,7 +2,7 @@
* PeggyDraw
* v 2.0
* by Windell H Oskay, Evil Mad Scientist Laboratories
- * portions by Matt Mets, cibomahto.com
+ * portions by Matt Mets, http://cibomahto.com
*
*/
@@ -19,16 +19,15 @@ int dimFillColor = 3; // This is the color stored in the animation fram
boolean pendown = false;
int pencolor;
-// Size of each cell in the grid
-int cellSize = 20;
-
// Number of columns and rows in our system
int cols = 25;
int rows = 25;
-//int cols = 13;
-//int rows = 9;
+int guiWidth = 500;
+int guiHeight = 125;
+// Size of each cell in the grid
+int cellSize = guiWidth/cols;
// Display colors
// TODO: Make these constants?
@@ -85,10 +84,10 @@ void updateFrameDuration(int duration) {
void setup() {
- frames = new AnimationFrames(cols,rows,100);
+ frames = new AnimationFrames(cols,rows);
// TODO: make sure this size makes sense.
- size(cellSize*cols, cellSize*rows + 125 , JAVA2D);
+ size(guiWidth, guiHeight + cellSize*rows, JAVA2D);
smooth();
font_MB24 = loadFont("Miso-Bold-24.vlw");
@@ -379,7 +378,14 @@ void mousePressed() {
frames.setCurrentPosition(frames.getCurrentPosition() + 1);
}
else if( addButton.isSelected() ) {
+ // Store the current duration so that we can copy it to the new frame
+ int duration = frames.getCurrentFrame().getDuration();
+
+ // Create the new frame
frames.addFrame(frames.getCurrentPosition()+1);
+
+ // Then copy the duration back over
+ frames.getCurrentFrame().setDuration(duration);
}
else if( durationTypeButton.isSelected() ) {
if (SteadyRate) {

0 comments on commit 4e2993c

Please sign in to comment.