scale from center of screen
in
Programming Questions
•
1 year ago
I want to scale from the center of the screen, but i don't want to use the scale() method.
What i have now works but there is probably a better way.
- ArrayList<PVector> vectors = new ArrayList<PVector>();
- void setup() {
- vectors.add(new PVector(30, 30));
- vectors.add(new PVector(70, 70));
- }
- void draw() {
- background(255);
- fill(0);
- stroke(0);
- float s = map(mouseX, 0, width, 0.5, 2);
- for (PVector v : vectors) {
- PVector tv = new PVector(v.x, v.y);
- tv.x -= width/2;
- tv.y -= height/2;
- tv.mult(s);
- tv.x += width/2;
- tv.y += height/2;
- ellipse(tv.x, tv.y, 5, 5);
- }
- }
1