Scaling/Translating a Shape to a given Rectangle using AffineTransform

后端 未结 2 1303
梦如初夏
梦如初夏 2020-12-02 00:54

I\'m trying to scale/translate a java.awt.Shape with AffineTransform in order to draw it in a defined bounding Rectangle.

Moreover,

2条回答
  •  我在风中等你
    2020-12-02 01:50

    Note that AffineTransform transformations are concatenated "in the most commonly useful way", which may be regarded as last in, first-out order. The effect can be seen in this example. Given the sequence below, the resulting Shape is first rotated, then scaled and finally translated.

    at.translate(SIZE/2, SIZE/2);
    at.scale(60, 60);
    at.rotate(Math.PI/4);
    return at.createTransformedShape(...);
    

提交回复
热议问题