play/graphics/Render.java (3298 bytes)
1 import java.awt.BasicStroke; 2 import java.awt.Color; 3 import java.awt.Font; 4 import java.awt.Graphics2D; 5 import java.awt.RenderingHints; 6 import java.awt.geom.Area; 7 import java.awt.geom.Ellipse2D; 8 import java.awt.geom.Rectangle2D; 9 import java.awt.image.BufferedImage; 10 import java.io.File; 11 import javax.imageio.ImageIO; 12 13 /** 14 * Renders the Play Store icon and feature graphic from the same geometry as 15 * res/drawable/ic_launcher_foreground.xml, so the store and the launcher agree. 16 * 17 * java Render.java (run from this directory; JDK 11+) 18 */ 19 public class Render { 20 21 static final Color INK = new Color(0x11, 0x11, 0x11); 22 23 /** The launcher glyph, drawn in its own 108-unit viewport. */ 24 static void glyph(Graphics2D g, double x, double y, double size) { 25 Graphics2D c = (Graphics2D) g.create(); 26 c.translate(x, y); 27 c.scale(size / 108.0, size / 108.0); 28 c.setColor(INK); 29 30 Area ring = new Area(new Ellipse2D.Double(30, 30, 48, 48)); 31 ring.subtract(new Area(new Ellipse2D.Double(38, 38, 32, 32))); 32 c.fill(ring); 33 c.fill(new Rectangle2D.Double(50, 46, 8, 16)); 34 c.fill(new Rectangle2D.Double(30, 50, 6, 8)); 35 c.fill(new Rectangle2D.Double(22, 50, 4, 8)); 36 c.fill(new Rectangle2D.Double(72, 50, 6, 8)); 37 c.fill(new Rectangle2D.Double(82, 50, 4, 8)); 38 c.dispose(); 39 } 40 41 static Graphics2D canvas(BufferedImage img) { 42 Graphics2D g = img.createGraphics(); 43 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 44 g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 45 g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); 46 g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); 47 g.setColor(Color.WHITE); 48 g.fillRect(0, 0, img.getWidth(), img.getHeight()); 49 return g; 50 } 51 52 public static void main(String[] a) throws Exception { 53 // Icon: Play applies its own rounded mask, so this is full-bleed white 54 // with the glyph enlarged to sit inside the safe zone. 55 BufferedImage icon = new BufferedImage(512, 512, BufferedImage.TYPE_INT_ARGB); 56 Graphics2D g = canvas(icon); 57 glyph(g, -96, -96, 704); 58 g.dispose(); 59 ImageIO.write(icon, "png", new File("icon-512.png")); 60 61 // Feature graphic: e-ink plain. Glyph left, name and promise right. 62 BufferedImage f = new BufferedImage(1024, 500, BufferedImage.TYPE_INT_RGB); 63 g = canvas(f); 64 glyph(g, -40, -55, 610); 65 g.setColor(INK); 66 g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 92)); 67 g.drawString("AssistKey", 500, 232); 68 g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 34)); 69 g.setColor(new Color(0x44, 0x44, 0x44)); 70 g.drawString("Remap every hardware key", 504, 296); 71 g.drawString("on your Viwoods AiPaper", 504, 342); 72 g.setColor(INK); 73 g.setStroke(new BasicStroke(3f)); 74 g.drawLine(504, 256, 584, 256); 75 g.dispose(); 76 ImageIO.write(f, "png", new File("feature-1024x500.png")); 77 78 System.out.println("wrote icon-512.png and feature-1024x500.png"); 79 } 80 }