Transforming Rectangles


#1

I have been messing around with Juce drawing routines and object, specifically rectangles and it appears that there is no way to conveniently transform a rectangle.

I understand it may be possible to transform it by using addTransform() method of the Graphics object but consider this situation.

I have two rectangles that need to be transformed, let's say rotated by a differing amount. I need to project both into a graphics boject and apply another transformation to the whole thing, say rotate it once again. What would be the best way to approach this?

My vision was to simply add transform matrices to each of the rectangles, then another transform to the graphics port and then draw the rectangles afterwards achieving the result, however it appears this is not how Juce operates, unless I am missing something.

Any suggestions?

 


#2

I found a solution to this using paths:

Rectangle<float> r = Rectangle<float>(10, 10, 100, 100);
AffineTransform t = AffineTransform::rotation(-0.57);

Path p;
p.addRectangle(r);
g.strokePath(p, PathStrokeType(1), t);