Hi guys
I’ve managed to create an animation that works (reading strings from tabulated data)! Woo hoo.
Except… I’ve made a few small changes to my tabular data, have re-saved it as a tsv file again (same name as before so should be no issues there?) and now my animation won’t work.
I’ve tried dragging and dropping it onto the code, accepted it as a new version and still nothing.
Can anyone give me some pointers on why it might not be recognizing the new tsv file?
Thanks in advance.
Nicole
Here is my code in case this gives any hints as to what I’ve done):
//final project - working file //<>// //<>//
color[] rainbow = {#169499, #BF0C2B, #F14C13, #FFD418, #03A63C, #04117B, #400A34, #02173E, #421F02, #0B080B, #F2055C, #D9D0B1, #F8A602, #F1F0F1};
String[] palette = {"aqua", "red", "orange", "yellow", "green", "blue", "purple", "indigo", "brown", "black", "pink", "grey", "grey", "white"};
int y = 600;
int dy = 0;
Bubble[][] myBubbles; // Array of bubble types
int revisedCount;
Table colorscultures;
int rowCount;
color bubbleColour = 0;// Bubble colours
int culturesSize = 8;//Header row
PImage bg;
void setup() {
size(1000, 600);
bg = loadImage("blue_sky.jpg");
image (bg, 0, 0);
smooth();
colorscultures = loadTable("colorscultures.tsv");
rowCount = colorscultures.getRowCount();
myBubbles = new Bubble[culturesSize][rowCount];
float myY = 0;
revisedCount = 0;
for (int z = 0; z < rowCount; z += 1) {
String colour = colorscultures.getString(z, 0);
String american = colorscultures.getString(z, 1);
String european = colorscultures.getString(z, 2);
String indian_hindu = colorscultures.getString(z, 3);
String muslim = colorscultures.getString(z, 4);
String asian = colorscultures.getString(z, 5);
String chinese = colorscultures.getString(z, 6);
String japanese = colorscultures.getString(z, 7);
String native_american = colorscultures.getString(z, 8);
//Settings (spacing) for where to display each bubble (layed out in columns)
setCultureBubbles(z, 100, myY, colour, american, 0);
setCultureBubbles(z, 200, myY, colour, european, 1);
setCultureBubbles(z, 300, myY, colour, indian_hindu, 2);
setCultureBubbles(z, 400, myY, colour, muslim, 3);
setCultureBubbles(z, 500, myY, colour, asian, 4);
setCultureBubbles(z, 600, myY, colour, chinese, 5);
setCultureBubbles(z, 700, myY, colour, japanese, 6);
setCultureBubbles(z, 800, myY, colour, native_american, 7);
//Space between bubbles as they come up
myY += 80;
//revisedCount += 1;
//}
}
//rowCount = revisedCount;
//myBubbles[0] = new Bubble(75, 0, 50, "H");
//myBubbles[1] = new Bubble(25, 0 - 30, 50, "S");
//myBubbles[2] = new Bubble(25, 0 - 60, 50, "S");
}
//What info to grab in order to create bubble when it reads data (x, y, colour, culture header, content)
void setCultureBubbles(int z, float myX, float myY, String colour, String culture, int cultureIndex)
{
boolean display = true;
if (culture.length() == 0)
{
display = false;
culture = "";
}
if (colour.length() != 0)
{
bubbleColour = getColour(colour);
}
myBubbles[cultureIndex][z] = new Bubble(random(10,990), myY, 70, culture, display, bubbleColour);
println(z + " Colour:" + bubbleColour);
}
//Get colour for bubble
color getColour(String colour) {
//int myColour = 0;
for (int count=0; count < palette.length; count += 1)
{
if (palette[count].equals(colour.toLowerCase()))
{
return rainbow[count];
}
}
return 0;
}
void draw() {
background (0);
image (bg, 0, 0);
smooth();
//stroke(#BF0C2B); //
//strokeWeight(1); //
//ellipse (100, y, 50, 50);
//ellipse (25, y + 50, 50, 50);
for (int count = 1; count < rowCount; count += 1)
{
for (int culturesCount = 0; culturesCount < culturesSize; culturesCount += 1)
{
myBubbles[culturesCount][count].display(y);
}
//myBubbles[2].display(y, "B");
//println(" Y: " + myBubbles[count].totalY);
}
println(" finish");
//ellipse (80, 80, 50, 50);
y = y + dy;
if (y <= 600) {
dy = -3;
}
//if(y > 0) {
// dy = 1;
//}
}
// This simple Bubble class draws a circle to the window
// and displays a text label when the mouse hovers.
class Bubble {
float x, y;
float diameter;
String name;
float totalY;
boolean display;
color colour;
boolean over = false;
// Create the Bubble
Bubble(float tempX, float tempY, float tempD, String s, boolean myDisplay, color myColour) {
x = tempX;
y = tempY;
diameter = tempD;
name = s;
display = myDisplay;
colour = myColour;
}
// Display the Bubble
void display(float myY) {
if (display)
{
//stroke(0,255,0);
//strokeWeight(2);
//color(myColour);
fill(colour); //fill colour of ellipse
totalY = y + myY;
//fill(colour);
stroke(#F1F0F1); //outside line of ellipse
strokeWeight(2);//for ellipse
textAlign(CENTER);
text(name, x, totalY);
ellipse(x, totalY, diameter, diameter);
x = x + random(-1, 1);
y--;
}
}
}