AffineTransform at;
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Color.black);
at = new AffineTransform();
at.setToTranslation(x, y);
at.setToRotation(theta);
g2.setTransform(at);
g2.drawPolygon(points);
我的代碼在x和y繪製三角形...當我按a和d三角形旋轉..但是當我按w和s時,三角形不會改變它x和y。Java旋轉和使用Graphics2d繪圖
的變量是正確的..它翻譯日常..我不知道這裏也有我錯了..
如果我這樣做:
AffineTransform at;
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Color.black);
at = new AffineTransform();
at.setToTranslation(x, y);
g2.setTransform(at);
g2.drawPolygon(points);
at.setToRotation(theta);
g2.setTransform(at);
g2.drawPolygon(points);
一個旋轉和一個移動..那麼爲什麼我不能在繪畫之前應用這兩種翻譯?