开发者

Why is g2d.rotate to 90 degrees not exactly 90 degrees? JAVA

Hi I am trying to create a circular text. I managed to do it somehow by for-looping each rotated character. But I still don't get it. I don't understand the angles. Could someone please give me a good explanation? Like in the following code why is a not exactly 90 degrees? But somewhere between 100 and 120?

Graphics2D g2d = (Graphics2D)g;
    AffineTransform xform1, cxform;
    xform1 = AffineTransform.getTranslateInstance(200,200);
    g2d.setTransform(xform1);
    g2d.drawLine(0, -20, 0, 20);
    g2d.drawLine(-开发者_运维问答20, 0, 20, 0);
    xform1.rotate(Math.toDegrees(90));
    g2d.setTransform(xform1);
    g2d.drawString("a", 0, 20);

My first post. Hope I have not made any mistakes. Thanks


You want to rotate by 90 degrees, but rotate takes radians - so your conversion is the wrong way round. You're converting 90 radians to degrees, and then passing that to something which expects radians :) Try this:

xform1.rotate(Math.toRadians(90));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜