Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Working version, move frames to a proper class, fix outstanding bugs

  • Loading branch information...
commit 7644a7b15b88bf6d70fa103d8c00debc946f393d 1 parent 06b6723
@cibomahto cibomahto authored
Showing with 382 additions and 485 deletions.
  1. +126 −0 AnimationFrame.pde
  2. +256 −485 PeggyDraw2.pde
View
126 AnimationFrame.pde
@@ -0,0 +1,126 @@
+
+// A collection of image frames, therefore an animation.
+class AnimationFrames
+{
+ private ArrayList frames; // List of all of the frames
+ private int current; // Current frame
+
+ protected int width;
+ protected int height;
+ int defaultDuration;
+
+ AnimationFrames(int width, int height, int defaultDuration)
+ {
+ this.width = width;
+ this.height = height;
+ this.defaultDuration = defaultDuration;
+
+ frames = new ArrayList();
+ addFrame(0);
+ }
+
+ AnimationFrame getCurrentFrame() {
+ return (AnimationFrame) frames.get(current);
+ }
+
+ void replaceCurrentFrame(AnimationFrame ref) {
+ frames.set(current, new AnimationFrame(ref));
+ }
+
+ int getFrameCount() {
+ return frames.size();
+ }
+
+ int getCurrentPosition() {
+ return current;
+ }
+
+ void setCurrentPosition(int position) {
+ if (position < getFrameCount() && position >= 0) {
+ current = position;
+ }
+ }
+
+ void addFrame(int position) {
+ // TODO: do we need to check that the position is in range?
+
+ frames.add(position, new AnimationFrame(width, height, defaultDuration));
+
+ current = position;
+ }
+
+ void removeFrame(int position) {
+ frames.remove(position);
+
+ // If we have deleted all of the frames, make a new blank one to be friendly.
+ if (frames.size() == 0) {
+ addFrame(0);
+ }
+
+ // If the current frame is now invalid, select one that is.
+ if (current >= frames.size()) {
+ current = frames.size() - 1;
+ }
+ }
+}
+
+// A single image frame
+class AnimationFrame
+{
+ int width;
+ int height;
+ int duration;
+ int frameData[];
+
+ AnimationFrame(AnimationFrame ref) {
+ width = ref.width;
+ height = ref.height;
+ duration = ref.duration;
+
+ // TODO: any better way to do this?
+ frameData = new int[height*width];
+ for (int i = 0; i < height*width; i++) {
+ frameData[i] = ref.frameData[i];
+ }
+ }
+
+ AnimationFrame(int width, int height, int duration) {
+ this.width = width;
+ this.height = height;
+ this.duration = duration;
+
+ frameData = new int[height*width];
+ preset(0);
+ }
+
+ // TODO: is this a good thing to provide?
+ void preset(int value) {
+ for(int i = 0; i < height*width; i++) {
+ frameData[i] = value;
+ }
+ }
+
+ int getPixel(int x, int y) {
+ if (x < width && y < height) {
+ return frameData[y*width+x];
+ }
+
+ // out of bounds, just fail silently.
+ return 0;
+ }
+
+ void setPixel(int x, int y, int value) {
+ // if we were out of bounds, just fail silently.
+ if (x < width && y < height) {
+ frameData[y*width+x] = value;
+ }
+ }
+
+ int getDuration() {
+ return duration;
+ }
+
+ void setDuration(int duration) {
+ this.duration = duration;
+ }
+}
View
741 PeggyDraw2.pde
@@ -2,333 +2,22 @@
* PeggyDraw
* v 2.0
* by Windell H Oskay, Evil Mad Scientist Laboratories
+ * portions by Matt Mets, cibomahto.com
*
*/
-
- /*
- Could really use some cleanup -- need to define a class for our GUI text buttons.
-
- A bug on reading back(?) the durations is still there.
-
- */
-
-
-int PeggyData[];
-int PeggyDurations[];
-
-int brightFillColor = 15;
-int StrokeColor = 2;
-int TextColor = 10;
-int TextHighLight = 15;
-
-int dimFillColor = 3;
-int bgColor = 1;
-int FrameCount = 1; // NUMBER of existing frames.
-int CurrentFrame = 1;
-int CurrentDuration = 100;
-
-//int SampX,SampY,SampZ;
-int DataX,DataY;
-
-color circleColor = color(255, 128, 0, 128);
-
-boolean SteadyRate = true;
-
-boolean overRect(int x, int y, int width, int height)
-{
- if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height)
- return true;
- else
- return false;
-}
-
-
-void StoreFrame()
-{
-int j = 0;
-int offset = 625*(CurrentFrame - 1);
-
- while (j < 625){
- PeggyData[offset + j] = GrayArray[j];
- j++;
- }
-
-
-}
-
-
-void RecallFrame(int theFrame)
-{
-int j = 0;
-int offset = 625*(theFrame - 1);
-
- while (j < 625){
- GrayArray[j] = PeggyData[offset + j];
- j++;
- }
-
- CurrentDuration = PeggyDurations[theFrame - 1];
-}
-
-
-void InsertFrame()
-{ // Insert one frame AFTER current frame, filled with zeroes.
-int j = 0;
-int offset = 625*(CurrentFrame);
-
- while (j < 625){
- PeggyData = splice(PeggyData, 0, offset);
- j++;
- }
-
- PeggyDurations = splice(PeggyDurations, CurrentDuration, CurrentFrame);
-}
-
+AnimationFrames frames; // Storage for our frame stack
+AnimationFrame copiedFrame; // Reference to the copied frame
-void DeleteFrame()
-{ // Remove the current frame from the PeggyData[] array.
-
-int[] firstpart = subset(PeggyData, 0, 625*(CurrentFrame - 1)); // subset(array, offset, length)
-int[] endpart = subset(PeggyData, 625*(CurrentFrame)); // subset(array, offset) -> to end!
-PeggyData = concat(firstpart, endpart);
-
-int[] FirstDur = subset(PeggyDurations, 0, CurrentFrame); // subset(array, offset, length)
-int[] EndDur = subset(PeggyDurations, CurrentFrame+1); // subset(array, offset) -> to end!
-PeggyDurations = concat(FirstDur, EndDur);
-
-}
-
-
-
-
-void mousePressed() {
-
- int mxin, myin;
- int x,y;
-
- if ((mouseX > 0) && (mouseX < cols*cellSize) && (mouseY > 0) && (mouseY < rows*cellSize))
- { // i.e., if we clicked within the LED grid
- mxin = floor( mouseX / cellSize);
- myin = floor( mouseY / cellSize);
+boolean SteadyRate = true; // True if all frames have the same duration
-// SampX = mxin;
-// SampY = myin;
-// SampZ = GrayArray[mxin*cols + myin];
+int DataX,DataY; // Offset to draw the data display at
- if ((GrayArray[mxin*cols + myin]) == brightFillColor) // if the dot is already in our color
- // if (true) // if the dot is already in our color
- pencolor = dimFillColor; // We're erasing
- else
- pencolor = brightFillColor; // We're drawing
+int brightFillColor = 15; // This is the color stored in the animation frame for 'on' pixels
+int dimFillColor = 3; // This is the color stored in the animation frame for 'off' pixels
- pendown = true;
- }
-
- else
- { // Check GUI buttons!
-
- if( clearButton.isSelected() ) {
- j = 0;
- while (j < 625){
- GrayArray[j] = 0;
- j++;
- }
- }
- else if( fillButton.isSelected() ) {
- j = 0;
- while (j < 625){
- GrayArray[j] = brightFillColor;
- j++;
- }
- }
- else if( invertButton.isSelected() ) {
- j = 0;
- while (j < 625) {
- if ( GrayArray[j] == brightFillColor )
- GrayArray[j] = 0;
- else
- GrayArray[j] = brightFillColor;
- j++;
- }
- }
- else if( copyButton.isSelected() ) {
- j = 0;
- while (j < 625) {
- Buffer[j] = GrayArray[j];
- j++;
- }
- }
- else if( pasteButton.isSelected() ) {
- j = 0;
- while (j < 625) {
- GrayArray[j] = Buffer[j];
- j++;
- }
- }
- else if( deleteButton.isSelected() ) {
- // TODO: has error.
- if ( FrameCount > 1)
- {
- FrameCount -= 1;
- DeleteFrame();
-
- if (CurrentFrame > FrameCount)
- CurrentFrame--;
-
- RecallFrame(CurrentFrame);
- }
- }
- else if( previousButton.isSelected() ) {
- if ( CurrentFrame > 1)
- {
- StoreFrame();
- CurrentFrame--;
- RecallFrame(CurrentFrame);
- CurrentDuration = PeggyDurations[CurrentFrame - 1];
- }
- }
- else if( nextButton.isSelected() ) {
- if (CurrentFrame < FrameCount)
- {
- StoreFrame();
-
- CurrentFrame++;
- RecallFrame(CurrentFrame);
- CurrentDuration = PeggyDurations[CurrentFrame - 1];
- }
- }
- else if( addButton.isSelected() ) {
- FrameCount += 1;
-
- StoreFrame();
- InsertFrame();
- CurrentFrame++;
- RecallFrame(CurrentFrame); //OK thus far...
-
- CurrentDuration = PeggyDurations[CurrentFrame - 1];
- }
- else if( loadButton.isSelected() ) {
- // Load in the data!
- }
- else if( saveButton.isSelected() ) {
- // Save out the data!
- }
- }
-
-/*
- y = cellSize*rows + 105;
- x = 110;
- if (overRect(x+5, y-18, 75, 18) )
- {
-// text("All frames:", x, y);
-
- if (SteadyRate)
- SteadyRate = false;
- else
- SteadyRate = true;
-}
- x += 100;
-
- x += 35;
- x += 35;
-
-if (overRect(x-3, y-18, 20, 18) )
- {
-// text("+", x, y);
-
-if (CurrentDuration <= 90)
- CurrentDuration += 10;
-else if (CurrentDuration <= 900)
- CurrentDuration += 100;
-else if (CurrentDuration <= 59000)
- CurrentDuration += 1000;
-else
- CurrentDuration = 60000;
-
-if (SteadyRate){
- j = 0;
- while (j < PeggyDurations.length){
- PeggyDurations[j] = CurrentDuration;
-
- j++;
- }
-}
-}
-
-
- x += 15;
- x += 15;
- if (overRect(x-3, y-18, 20, 18) )
- {
-// text("-", x, y);
-
-if (CurrentDuration >= 2000 )
- CurrentDuration -= 1000;
-else if (CurrentDuration >= 200 )
- CurrentDuration -= 100;
-else if (CurrentDuration >= 20 )
- CurrentDuration -= 10;
-else
- CurrentDuration = 10;
-
-
- if (SteadyRate){
- j = 0;
- while (j < PeggyDurations.length){
- PeggyDurations[j] = CurrentDuration;
-
- j++;
- }
-}
-}
-
-*/
-
- /*
- // Handle other interface bits here as well!
-
- if ( buttonSave.over ) { //Save output file
- String comma = ",";
-
- for (int i = 0; i < rows; i++) {
- // Begin loop for rows
- rowdata = 0;
- for (int j = 0; j < cols; j++) {
-
- if (GrayArray[i*cols + j] > 0)
- {
- rowdata += (1 << j);
- }
- }
-
- if (i == (rows - 1))
- header = append(header, str(rowdata));
- else
- header = append(header, str(rowdata) + ',');
- }
- FileOutput = concat(header, footer);
-
- File outputDir = new File(sketchPath, "PeggyProgram");
- if (!outputDir.exists())
- outputDir.mkdirs();
-
- saveStrings("PeggyProgram/PeggyProgram.pde", FileOutput);
- //Note: "/" apparently works as a path separator on all operating systems.
-
- for (int j = 0; j < rows; j++) {
- for (int i = 0; i < cols; i++) {
-
- }
- }
- }
- */
-
-}
-
-void mouseReleased() {
- pendown = false;
-}
+boolean pendown = false;
+int pencolor;
// Size of each cell in the grid
int cellSize = 20;
@@ -337,27 +26,20 @@ int cellSize = 20;
int cols = 25;
int rows = 25;
+// Display colors
+// TODO: Make these constants?
+int TextColor = 10;
+int TextHighLight = 15;
+int bgColor = 1;
+
+/*
String[] header;
String[] RowData;
String[] footer;
String[] FileOutput;
String[] OneRow;
+*/
-int[] GrayArray = new int[625]; // Single frame
-int[] Buffer = new int[625]; // Clipboard
-
-
-int Brightness;
-int j;
-byte k;
-boolean pendown = false;
-int pencolor;
-
-int rowdata;
-
-//ImageButtons buttonErase, buttonFill, buttonSave;
-
-PFont font_MB48;
PFont font_MB24;
PFont font_ML16;
@@ -372,48 +54,48 @@ SimpleButton previousButton;
SimpleButton nextButton;
SimpleButton loadButton;
SimpleButton saveButton;
+SimpleButton durationTypeButton;
+SimpleButton durationPlusButton;
+SimpleButton durationMinusButton;
+
-void setup() {
-
-// UpFrame = false;
-
- PeggyData = new int[625];
- PeggyDurations = new int[1];
-
- PeggyDurations[0] = 100;
-
+boolean overRect(int x, int y, int width, int height)
+{
+ if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height)
+ return true;
+ else
+ return false;
+}
+
+
+void setup() {
+
+ frames = new AnimationFrames(cols,rows,100);
+
+ // TODO: make sure this size makes sense.
size(cellSize*cols, cellSize*rows + 125 , JAVA2D);
smooth();
-
- font_MB48 = loadFont("Miso-Bold-48.vlw");
+
font_MB24 = loadFont("Miso-Bold-24.vlw");
font_ML16 = loadFont("Miso-Light-16.vlw");
- // textFont( font_MB24, 20); // MISO Typeface from http://omkrets.se/typografi/
-
- int x,y;
-
+/*
header = loadStrings("PeggyHeader.txt");
footer = loadStrings("PeggyFooter.txt");
+*/
colorMode(RGB, 15); // Max value of R, G, B = 15.
ellipseMode(CORNER);
-
- j = 0;
- k = 0;
-
- while (j < 625){
- GrayArray[j] = 0;
- Buffer[j]= 0;
- j++;
- }
+
strokeWeight(1);
- stroke(StrokeColor); // Set color: Gray outline for LED locations.
-
+ stroke(2); // Set color: Gray outline for LED locations.
+
DataX = 15;
DataY = cellSize*rows +25;
-
+
+ int x,y;
+
x = 110;
y = cellSize*rows + 25;
clearButton = new SimpleButton("Clear", x, y, font_MB24, 24, TextColor, TextHighLight);
@@ -425,7 +107,7 @@ void setup() {
copyButton = new SimpleButton("Copy", x, y, font_MB24, 24, TextColor, TextHighLight);
x += 75;
pasteButton = new SimpleButton("Paste", x, y, font_MB24, 24, TextColor, TextHighLight);
-
+
x = 105;
y = cellSize*rows + 65;
deleteButton = new SimpleButton("-Frame", x, y, font_MB24, 24, TextColor, TextHighLight);
@@ -435,15 +117,19 @@ void setup() {
nextButton = new SimpleButton(">>", x, y, font_MB24, 24, TextColor, TextHighLight);
x += 60;
addButton = new SimpleButton("+Frame", x, y, font_MB24, 24, TextColor, TextHighLight);
-
+
x = 110;
y = cellSize*rows + 105;
// toggle button
- x += 100;
+ durationTypeButton = new SimpleButton("All frames:", x, y, font_MB24, 24, TextColor, TextHighLight);
+
+ x += 170;
// duration decrease button
+ durationPlusButton = new SimpleButton("+", x, y, font_MB24, 24, TextColor, TextHighLight);
+
x += 15 + 15;
- // duration increase button
-
+ durationMinusButton = new SimpleButton("-", x, y, font_MB24, 24, TextColor, TextHighLight);
+
x = 375;
loadButton = new SimpleButton("Load", x, y, font_MB24, 24, TextColor, TextHighLight);
x += 65;
@@ -452,23 +138,20 @@ void setup() {
} // End Setup
-void draw() {
-
+void draw() {
int mxin, myin;
int i,j,x,y;
background(bgColor);
-
- // stroke(StrokeColor); // Set color: Gray outline for LED locations.
- for ( i = 0; i < cols; i++) {
- // Begin loop for rows
- for ( j = 0; j < rows; j++) {
+ AnimationFrame currentFrame = frames.getCurrentFrame();
- if (GrayArray[i*cols + j] > 0)
+ for ( i = 0; i < currentFrame.width; i++) {
+ for ( j = 0; j < currentFrame.height; j++) {
+ if (currentFrame.getPixel(i, j) > 0)
fill(brightFillColor);
else
- fill(dimFillColor);
+ fill(dimFillColor);
ellipse(i*cellSize + 1, j*cellSize + 1, cellSize - 1 , cellSize- 1);
}
@@ -484,17 +167,17 @@ void draw() {
myin = floor( mouseY / cellSize);
if(mousePressed && pendown)
- {
+ {
if (pencolor == brightFillColor)
- GrayArray[mxin*cols + myin] = brightFillColor;
+ currentFrame.setPixel(mxin, myin, brightFillColor);
else
- GrayArray[mxin*cols + myin] = 0;
+ currentFrame.setPixel(mxin, myin, 0);
}
// Position Display:
- fill(8);
- textFont(font_MB24, 24);
+ fill(8);
+ textFont(font_MB24, 24);
if (mxin > 9)
text(mxin, DataX - 10, DataY);
@@ -513,13 +196,13 @@ void draw() {
}
fill(5);
- textFont(font_ML16, 16);
-
+ textFont(font_ML16, 16);
+
x = 10;
y = cellSize*rows + 110;
text("PeggyDraw 2", x, y);
- textFont(font_MB24, 24);
+ textFont(font_MB24, 24);
fill(TextColor);
DrawButtons();
@@ -527,7 +210,7 @@ void draw() {
textFont(font_ML16, 16);
fill(TextHighLight);
String message = new String("");
-
+
// Display mouseover text!
if (clearButton.isSelected()) {
message = "Erase this frame";
@@ -562,22 +245,23 @@ void draw() {
else if (saveButton.isSelected()) {
message = "Export program for Arduino";
}
-
+ else if (durationTypeButton.isSelected()) {
+ message = "Toggle: All frames or just this one";
+ }
+ else if (durationPlusButton.isSelected()) {
+ message = "Increase time per frame";
+ }
+ else if (durationMinusButton.isSelected()) {
+ message = "Decrease time per frame";
+ }
+
if (message != "") {
text(message, DataX, DataY-10, 75, 100);
}
// TODO: remove me
textFont(font_MB24, 24);
- fill(TextColor);
-
- x = 110;
- y = cellSize*rows + 25;
-
- x += 75;
- x += 65;
- x += 85;
- x += 75;
+ fill(TextColor);
x = 105;
@@ -585,111 +269,198 @@ void draw() {
x += 85;
x += 45;
- text(CurrentFrame, x, y);
+ text(frames.getCurrentPosition() + 1, x, y);
x += 30;
text("/", x, y);
x += 25;
- text(FrameCount, x, y);
-
- x += 45;
- x += 60;
-
+ text(frames.getFrameCount(), x, y);
y = cellSize*rows + 105;
- x = 110;
-
- if (SteadyRate)
- text("All frames: ", x, y);
- else
- text("This frame: ", x, y);
-
- if (overRect(x+5, y-18, 75, 18) )
- {
- //fill(circleColor);
- //rect(x+5, y-18, 75, 18);
+ x = 110;
- fill(TextHighLight);
+ x += 100;
- if (SteadyRate)
- text("All frames: ", x, y);
- else
- text("This frame: ", x, y);
+ if (currentFrame.getDuration() < 1000) {
+ text(currentFrame.getDuration(), x, y);
+ x += 35;
+ text("ms", x, y);
+ }
+ else if (currentFrame.getDuration() < 10000)
+ {
+ x += 10;
+ text(currentFrame.getDuration()/1000, x, y);
+ x += 25;
+ text("s", x, y);
+ }
+ else {
+ text(currentFrame.getDuration()/1000, x, y);
+ x += 35;
+ text("s", x, y);
+ }
+ x += 35;
+ x += 15;
+ text("/", x, y);
- textFont(font_ML16, 16);
+} // end main loop
- text("Toggle: All frames or just this one", DataX, DataY-10, 75, 100);
- textFont(font_MB24, 24);
- fill(TextColor);
- }
-
-
-
-
-
-
- x += 100;
-
- if (CurrentDuration < 1000){
- text(CurrentDuration, x, y);
- x += 35;
- text("ms", x, y);
- }
- else if (CurrentDuration < 10000)
- {
- x += 10;
- text(CurrentDuration/1000, x, y);
- x += 25;
- text("s", x, y);
- }
- else {
- text(CurrentDuration/1000, x, y);
- x += 35;
- text("s", x, y);
- }
-
- x += 35;
+void mousePressed() {
-text("+", x, y);
-if (overRect(x-3, y-18, 20, 18) )
- {
- //fill(circleColor);
- //rect(x-3, y-18, 20, 18);
+ int mxin, myin;
+ int x,y;
- fill(TextHighLight);
- text("+", x, y);
+ AnimationFrame currentFrame = frames.getCurrentFrame();
- textFont(font_ML16, 16);
+ if ((mouseX > 0) && (mouseX < cols*cellSize) && (mouseY > 0) && (mouseY < rows*cellSize))
+ { // i.e., if we clicked within the LED grid
+ mxin = floor( mouseX / cellSize);
+ myin = floor( mouseY / cellSize);
- text("Increase time per frame.", DataX, DataY-10, 75, 100);
- textFont(font_MB24, 24);
- fill(TextColor);
- }
-
-
- x += 15;
- text("/", x, y);
- x += 15;
- text("-", x, y);
- if (overRect(x-3, y-18, 20, 18) )
- {
- //fill(circleColor);
- //rect(x-3, y-18, 20, 18);
-
- fill(TextHighLight);
- text("-", x, y);
-
- textFont(font_ML16, 16);
-
- text("Decrease time per frame.", DataX, DataY-10, 75, 100);
- textFont(font_MB24, 24);
- fill(TextColor);
- }
-
- x = 375;
- x += 65;
+ // if the dot is already in our color
+ if (currentFrame.getPixel(mxin, myin) == brightFillColor)
+ // if (true) // if the dot is already in our color
+ pencolor = dimFillColor; // We're erasing
+ else
+ pencolor = brightFillColor; // We're drawing
-} // end main loop
+ pendown = true;
+ }
+
+ else
+ { // Check GUI buttons!
+
+ if( clearButton.isSelected() ) {
+ currentFrame.preset(0);
+ }
+ else if( fillButton.isSelected() ) {
+ currentFrame.preset(brightFillColor);
+ }
+ else if( invertButton.isSelected() ) {
+ // For each pixel in the frame, invert it...
+ for ( int i = 0; i < currentFrame.width; i++) {
+ for ( int j = 0; j < currentFrame.height; j++) {
+ if (currentFrame.getPixel(i, j) > 0)
+ currentFrame.setPixel(i, j, 0);
+ else
+ currentFrame.setPixel(i, j, brightFillColor);
+ }
+ }
+ }
+ else if( copyButton.isSelected() ) {
+ // Store a copy of the current frame
+ copiedFrame = new AnimationFrame(frames.getCurrentFrame());
+ }
+ else if( pasteButton.isSelected() ) {
+ // Replace the current frame with our stored copy
+ if (copiedFrame != null) {
+ frames.replaceCurrentFrame(copiedFrame);
+ }
+ }
+ else if( deleteButton.isSelected() ) {
+ frames.removeFrame(frames.getCurrentPosition());
+ }
+ else if( previousButton.isSelected() ) {
+ frames.setCurrentPosition(frames.getCurrentPosition() - 1);
+ }
+ else if( nextButton.isSelected() ) {
+ frames.setCurrentPosition(frames.getCurrentPosition() + 1);
+ }
+ else if( addButton.isSelected() ) {
+ frames.addFrame(frames.getCurrentPosition()+1);
+ }
+ else if( durationTypeButton.isSelected() ) {
+ if (SteadyRate) {
+ SteadyRate = false;
+ durationTypeButton.updateLabel("This frame: ");
+ }
+ else {
+ SteadyRate = true;
+ durationTypeButton.updateLabel("All frames: ");
+ }
+ }
+ else if( durationPlusButton.isSelected() ) {
+ int duration = currentFrame.getDuration();
+ if (duration <= 90)
+ duration += 10;
+ else if (duration <= 900)
+ duration += 100;
+ else if (duration <= 59000)
+ duration += 1000;
+ else
+ duration = 60000;
+ currentFrame.setDuration(duration);
+ if (SteadyRate) {
+ // TODO
+ }
+ }
+ else if( durationMinusButton.isSelected() ) {
+ int duration = currentFrame.getDuration();
+
+ if (duration >= 2000 )
+ duration -= 1000;
+ else if (duration >= 200 )
+ duration -= 100;
+ else if (duration >= 20 )
+ duration -= 10;
+ else
+ duration = 10;
+
+ currentFrame.setDuration(duration);
+
+ if (SteadyRate) {
+ // TODO
+ }
+ }
+ else if( loadButton.isSelected() ) {
+ // TODO: Load in the data!
+ }
+ else if( saveButton.isSelected() ) {
+ // TODO: Save out the data!
+ }
+ }
+}
+
+void mouseReleased() {
+ pendown = false;
+}
+
+
+/*
+ if ( buttonSave.over ) { //Save output file
+ String comma = ",";
+
+ for (int i = 0; i < rows; i++) {
+ // Begin loop for rows
+ rowdata = 0;
+ for (int j = 0; j < cols; j++) {
+
+ if (GrayArray[i*cols + j] > 0)
+ {
+ rowdata += (1 << j);
+ }
+ }
+
+ if (i == (rows - 1))
+ header = append(header, str(rowdata));
+ else
+ header = append(header, str(rowdata) + ',');
+ }
+ FileOutput = concat(header, footer);
+
+ File outputDir = new File(sketchPath, "PeggyProgram");
+ if (!outputDir.exists())
+ outputDir.mkdirs();
+
+ saveStrings("PeggyProgram/PeggyProgram.pde", FileOutput);
+ //Note: "/" apparently works as a path separator on all operating systems.
+
+ for (int j = 0; j < rows; j++) {
+ for (int i = 0; i < cols; i++) {
+
+ }
+ }
+ }
+ */
Please sign in to comment.
Something went wrong with that request. Please try again.