日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java轴_JAVA2D:翻译轴

發布時間:2025/3/21 编程问答 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java轴_JAVA2D:翻译轴 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

測試

public void BottomLeftOriginTest()引發IOException{

int寬度=256;

內部高度=512;

bufferedimage bi=新bufferedimage(寬度、高度、bufferedimage.type_int_bgr);

graphics2d ig=bi.creategraphics();

//保存“舊”轉換

affinetransform old=ig.getTransform();

//原點在左上方:

//使用反轉的Y變換更新圖形對象

如果(真)/*訂購正常*/

ig.比例(1.0,-1.0);

ig.translate(0,-bi.getheight());

}否則{

ig.translate(0,-bi.getheight());

ig.比例(1.0,-1.0);

}

int xpoints[]=新int[]0,寬度,寬度

int ypoints[]=新int[]0,高度,0

int npoints=xpoints.length;

ig.setcolor(顏色.藍色);

ig.fillRect(0,0,bi.getWidth(),bi.getHeight());

ig.setcolor(顏色,紅色);

ig.圓角多邊形(xpoints、ypoints、npoints);

//還原舊轉換

ig.settransform(舊版);

//將結果導出到文件

imageio.write(bi,“png”,新文件(“origin.png”));

}

< /代碼>

LP未來的某人:

@Test

public void bottomLeftOriginTest() throws IOException {

int width = 256;

int height = 512;

BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);

Graphics2D ig = bi.createGraphics();

// save the "old" transform

AffineTransform old = ig.getTransform();

// origin is top left:

// update graphics object with the inverted y-transform

if (true) { /* order ok */

ig.scale(1.0, -1.0);

ig.translate(0, -bi.getHeight());

} else {

ig.translate(0, -bi.getHeight());

ig.scale(1.0, -1.0);

}

int xPoints[] = new int[] { 0, width, width };

int yPoints[] = new int[] { 0, height, 0 };

int nPoints = xPoints.length;

ig.setColor(Color.BLUE);

ig.fillRect(0, 0, bi.getWidth(), bi.getHeight());

ig.setColor(Color.RED);

ig.fillPolygon(xPoints, yPoints, nPoints);

// restore the old transform

ig.setTransform(old);

// Export the result to a file

ImageIO.write(bi, "PNG", new File("origin.png"));

}

總結

以上是生活随笔為你收集整理的java轴_JAVA2D:翻译轴的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。