| | |
| | | package com.yeshi.fanli.util;
|
| | |
|
| | | import java.awt.AlphaComposite;
|
| | | import java.awt.BasicStroke;
|
| | | import java.awt.Color;
|
| | | import java.awt.Font;
|
| | |
| | |
|
| | | // 画邀请码(邀请码的大小与字体固定)
|
| | | if (!StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | |
| | | int ax = pX - (inviteCode.length() - 4)*13 ;
|
| | | int ay = pY + size + 118;
|
| | | |
| | | int width_diap = 235 + (int) (24.6 * (inviteCode.length() - 4));
|
| | | g2d.setColor(Color.white);
|
| | | // 画出一个矩形
|
| | | g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.65f)); // 透明度 |
| | | g2d.fillRect(ax, ay - 38, width_diap, 50);
|
| | | // 前半圆
|
| | | g2d.fillArc(ax - 25, ay- 38, 50, 50, 90, 180);
|
| | | // 后半圆
|
| | | g2d.fillArc(ax + width_diap - 25, ay- 38, 50, 50, 270, 180);
|
| | | |
| | | g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 1f)); |
| | | String st = "邀请码:" + inviteCode;
|
| | | String os = System.getProperty("os.name");
|
| | | String fontBoldPath = "/usr/share/fonts/PingFang_Medium.ttf";
|
| | |
| | | } catch (FontFormatException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | g2d.setFont(boldFont);
|
| | | g2d.getFontMetrics(boldFont);
|
| | | g2d.setColor(new Color(0, 0, 0));
|
| | |
|
| | | int ax = pX - 30;
|
| | | int ay = pY + size + 118;
|
| | | |
| | | g2d.setColor(new Color(0, 0, 0));
|
| | | g2d.drawString(st, ax, ay);
|
| | |
|
| | | }
|
| | |
|
| | | OutputStream out = new FileOutputStream(new File(targetPath));
|