javajwt图形设计是怎样的
本篇文章为大家展示了java jwt图形设计是怎样的,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
网站建设哪家好,找创新互联建站!专注于网页设计、网站建设、微信开发、小程序设计、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了岳麓免费建站欢迎大家使用!
#java jwt图形设计
创建透明图层方式
方式一
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);
创建图形
画圆形
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);
画正方形
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);
画椭圆
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);
画线
Line2D line= new Line2D.Double(conerX,conerY,conerX-200,conerY-200);
多边形
int px1[]={50,90,10,50};//首末点相重,才能画多边形 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);
画弧线
g.drawArc(10,40,90,50,0,180);//画圆弧线
抠图
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))方法替换 //如果需要设置透明度,添加这句代码 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); //消除画图锯齿 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
上述内容就是java jwt图形设计是怎样的,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。
本文标题:javajwt图形设计是怎样的
分享路径:http://lswzjz.com/article/jsphci.html