Skip to content

Commit

Permalink
New frames take on the duration of the current frame, display will sc…
Browse files Browse the repository at this point in the history
…ale to different LED sizes correctly.
  • Loading branch information
cibomahto committed Dec 15, 2010
1 parent b0a5d32 commit 4e2993c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
12 changes: 6 additions & 6 deletions AnimationFrame.pde
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -75,6 +73,8 @@ class AnimationFrame
int height;
int duration;
int frameData[];

int defaultDuration = 100;

AnimationFrame(AnimationFrame ref) {
width = ref.width;
Expand All @@ -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);
Expand Down
22 changes: 14 additions & 8 deletions PeggyDraw2.pde
Expand Up @@ -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
*
*/

Expand All @@ -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?
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4e2993c

Please sign in to comment.