Re: Graphics transforms
- From: "Daniel Pitts" <googlegroupie@xxxxxxxxxxxxx>
- Date: 19 Mar 2007 16:05:20 -0700
On Mar 19, 11:45 am, "visionset" <s...@xxxxxxxxxxxx> wrote:
I'm drawing a Rectangle somewhere on a Graphics object over an image and
rotating it some degrees about its centre.
I now want to use that rectangle to describe the part of the image I want to
grab.
To grab it I'm stuffing it in a BufferedImage by drawing on its Graphics
like so:
// rect is a Shape
// origin is the min x & min y of the rectangle
Point centre = rect.getCentre();
g2.rotate(-rect.getTheta(), centre.x, centre.y);
Point orig = rect.getOrigin();
g2.translate(-orig.x, -orig.y);
g2.setClip(rect);
renderTiles(g2);
The rotation works fine. But I can't figure out the translation to get it
back to 0,0
Any clues folks?
TIA
--
Mike W
You reverse the translations you've done.
g2d.translate(orig.x, orig.y);
g2d.rotate(rect.getTheta(), centre.x, centre.y);
.
- Follow-Ups:
- Re: Graphics transforms
- From: visionset
- Re: Graphics transforms
- References:
- Graphics transforms
- From: visionset
- Graphics transforms
- Prev by Date: Re: Automatically resize font when component size changes?
- Next by Date: Re: Graphics transforms
- Previous by thread: Graphics transforms
- Next by thread: Re: Graphics transforms
- Index(es):
Relevant Pages
|
|