vertical scale and rotate without warp
in
Programming Questions
•
2 years ago
hello
I am writing a program that distributes .svg's around a circle and am having a problem with a transformation i want to apply. I have simulated the problem with a triangle in the code below.
Basically i want to change the vertical scale of a shape independently of the horizontal scale and then distribute shapes evenly around a circle. When i apply the transformation the circle warps. I understand why this is happening as I am doing scale > rotate > draw but can't find a way around the issue. Have tried draw > scale > rotate which also doesn't work for obvious reasons...
Any help would be well appreciated cheers...
- int numTri;
- float gap;
- void setup() {
- size(500, 500);
- background(0);
- noFill();
- stroke(255);
- smooth();
- numTri = 8;
- }
- void draw() {
- }
- void mouseClicked() {
- background(0);
- drawCirc();
- }
- void drawCirc() {
- gap = radians(360)/numTri;
- for(int i = 0; i < numTri; i++) {
- pushMatrix();
- translate(mouseX, mouseY);
- scale(1, 0.5);
- rotate(i * gap);
- triangle(0, 0, -50, -200, 50, -200);
- popMatrix();
- }
- }
1