Why will my svg's not scale?

I can not get the svg's that I created to scale. Does anyone have any suggestions on how to fix this? Here is my code:

PShape Germany;
PShape Norway;
PShape SovietUnion;
PShape Austria;
PShape UnitedStates;
PShape[] countries;
int numCountries;

Table countryData;

void setup() {
  size(1000, 500); 



  Germany = loadShape("Germany.svg");
  Norway = loadShape("Norway.svg");
  SovietUnion = loadShape("Soviet Union.svg");
  Austria = loadShape("Austria.svg");
  UnitedStates = loadShape("United States.svg");
  countryData = loadTable("medals.csv", "header"); 
  parseFlags();
  noStroke();
  smooth();
  noLoop();
}

void draw() {
  background(200);
  parseTable();
  }


void parseTable() {
  for (TableRow row: countryData.rows()) {
    String country = row.getString("Country");
    float number = row.getFloat("Total");
    int num = myIndex(country);
    pushMatrix();
    shape(SovietUnion, 600, 600);
      scale(1.1);
    shape(Austria, 70, 70);
      scale(1.1);
    shape(Germany, 800, 800);
      scale(1.2);
    shape(UnitedStates,900,90);
      scale(1.4);
    shape(Norway,1000,100);
      scale(1.7);
      popMatrix();
  }
}
int myIndex(String icountryCode) {
  println("I want to find: " + icountryCode);
  int position = 0;
  return position;
}

void parseFlags() {
  numCountries = Germany.getChildCount();
  numCountries = Norway.getChildCount();
  numCountries = UnitedStates.getChildCount();
  numCountries = SovietUnion.getChildCount();
  numCountries = Austria.getChildCount();
  countries = new PShape[numCountries];
}
Tagged:

Answers

  • Some random remarks:

    • parseFlags() seems faulty: only the last numCountries assignment will be kept, the previous ones will be lost.
    • Not sure why you put your country drawings in a loop, it will just draw them over and over.
    • It is a bit strange that you call scale() after the drawing command.
    • Do you know that the effect of the scale() calls cumulate (within the same draw() call)?
    • How do you know they don't scale?
Sign In or Register to comment.