本篇文章為大家展示了java jwt圖形設(shè)計(jì)是怎樣的,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)建站!專(zhuān)注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、小程序設(shè)計(jì)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶(hù)創(chuàng)新互聯(lián)還提供了岳麓免費(fèi)建站歡迎大家使用!
#java jwt圖形設(shè)計(jì)
方式一
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); BufferedImageGraphicsConfig config = BufferedImageGraphicsConfig.getConfig(bufferedImage); bufferedImage = config.createCompatibleImage(width, height, Transparency.TRANSLUCENT);
方式二
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = bufferedImage.createGraphics(); bufferedImage = graphics.getDeviceConfiguration() .createCompatibleImage(width, height, Transparency.TRANSLUCENT);
方式三
ColorModel cm = ColorModel.getRGBdefault(); WritableRaster wr = cm.createCompatibleWritableRaster(width, height); BufferedImage bufferedImage = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
畫(huà)圓形
double centerX=1000/2; double centerY=1000/2; double conerX=centerX+100; double conerY=centerY+100; Ellipse2D circle=new Ellipse2D.Double(); double radius=Point2D.distance(centerX, centerY, conerX, conerY); circle.setFrameFromCenter(centerX,centerY,centerX+radius,centerY+radius); graphics.draw(circle);
畫(huà)正方形
double centerX=1000/2; double centerY=1000/2; double conerX=centerX+100; double conerY=centerY+50; Rectangle2D rect =new Rectangle2D.Double(); rect.setFrameFromCenter(centerX,centerY,conerX,conerY);
畫(huà)橢圓
double centerX=1000/2; double centerY=1000/2; double conerX=centerX+100; double conerY=centerY+50; Rectangle2D rect =new Rectangle2D.Double(); rect.setFrameFromCenter(centerX,centerY,conerX,conerY); Ellipse2D ellipse=new Ellipse2D.Double(); ellipse.setFrame(rect);
畫(huà)線(xiàn)
Line2D line= new Line2D.Double(conerX,conerY,conerX-200,conerY-200);
多邊形
int px1[]={50,90,10,50};//首末點(diǎn)相重,才能畫(huà)多邊形 int py1[]={10,50,50,10}; int px2[]={140,180,170,180,140,100,110,140}; int py2[]={5,25,35,45,65,35,25,5}; g.setColor(Color.blue); g.fillPolygon(px1,py1,4); g.setColor(Color.red); g.drawPolygon(px2,py2,9);
畫(huà)弧線(xiàn)
g.drawArc(10,40,90,50,0,180);//畫(huà)圓弧線(xiàn)
BufferedImage inputImage = ImageIO.read(new File("/Users/manager/Desktop/tupian.png")); Rectangle2D rectangle = new Rectangle(0,0,inputImage.getWidth(),inputImage.getHeight()); TexturePaint tPaint = new TexturePaint(inputImage,rectangle); BufferedImage bufferedImage = new BufferedImage(100,100,BufferedImage.TYPE_4BYTE_ABGR); Graphics2D g = bufferedImage.createGraphics(); g.setPaint(tPaint);//填充顏色可以使用g.setColor(new Color(0,204,255))方法替換 //如果需要設(shè)置透明度,添加這句代碼 g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC,0.5f)); g.fillPolygon(new int[]{0,100,100,0},new int[]{0,0,100,100},4); g.dispose(); ImageIO.write(bufferedImage,"png",new File("/Users/manager/Desktop/tupian3.png"));
//消除文字鋸齒 g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); //消除畫(huà)圖鋸齒 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
上述內(nèi)容就是java jwt圖形設(shè)計(jì)是怎樣的,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。