keeping an equal distance between 2 objects that are scaled differently

I'm working on a data visualization in which two images represent a relationship. One image is constantly scaled by .5 while the other is scaled by various percentages depending on the data selected. What I'd like to do is keep a constant spacing between these two images on the x-axis. But I'm not sure how do get that to happen. I've recreated the essential part of the code using rectangles instead of the SVG file.

float randPercentage;

void setup() {
  size(1400, 900);
  randPercentage = random(1, 100)/100;
  println(randPercentage);
}

void draw() {

  //object 1 (constant scale)
  pushMatrix();
  translate(1100, 400);
  rotate(radians(270));
  scale(.5);
  rect(0, 0, 600, 200);
  popMatrix();

  //object 2
  pushMatrix();
  translate(1100, 400);
  rotate(radians(270));
  scale(randPercentage);
  rect(0, 0, 600, 200);
  popMatrix();
}

thank you!!

Tagged:

Answers

Sign In or Register to comment.