TITLE:Shapeの反転
#navi(../)
RIGHT:Posted by [[terai]] at 2008-07-28
*Shapeの反転 [#ac299306]
AffineTransform で図形や画像を反転します。

-&jnlp;
-&jar;
-&zip;

#screenshot

**サンプルコード [#ie746204]
#code{{
Font font = new Font("Monospace", Font.PLAIN, 200);
FontRenderContext frc = new FontRenderContext(null, true, true);
Shape copyright = new TextLayout("\u00a9", font, frc).getOutline(null);
AffineTransform at = AffineTransform.getScaleInstance(-1.0, 1.0);
//Rectangle r = copyright.getBounds();
//at.translate(r.getWidth(), r.getHeight());
//AffineTransform at = new AffineTransform(-1d,0,0,1d,r.getWidth(), r.getHeight());
Shape copyleft = at.createTransformedShape(copyright);
}}

**解説 [#m5fa2d66]
上記のサンプルでは、コピーライトの文字を鏡像(左右)反転して、コピーレフトのアイコン(([[コピーレフト - Wikipedia>http://en.wikipedia.org/wiki/Copyleft]]))を作成しています。

上下反転の場合は、AffineTransform.getScaleInstance(1.0, -1.0)を使用します。

//**参考リンク
**コメント [#c9ea5267]
#comment