New application icon on both apps
Rubin's vase with a headset: the vase's outline is two faces looking at each other, one talking into the microphone. Blue on transparent; the Android launcher puts it on white, as no launcher shows a transparent adaptive icon. Desktop windows, tray, the .desktop entry and the macOS dock all use it, with a bolder variant below 32 px. ts3-client/tools/AppIcon.java generates the SVGs and the launcher foreground. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".Ts3Application"
|
android:name=".Ts3Application"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@android:style/Theme.Material.NoActionBar">
|
android:theme="@android:style/Theme.Material.NoActionBar">
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generated by ts3-client/tools/AppIcon.java; the art sits in the adaptive icon's safe zone. -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="256"
|
||||||
|
android:viewportHeight="256">
|
||||||
|
<group
|
||||||
|
android:scaleX="0.62"
|
||||||
|
android:scaleY="0.62"
|
||||||
|
android:pivotX="128"
|
||||||
|
android:pivotY="128">
|
||||||
|
<path android:pathData="M128,6.9C68.5,6.9 18.3,48.4 16.1,102.2L16.1,102.2C10.2,104.5 6,110.3 6,117L6,139.5C6,148.4 13.2,155.5 22,155.5L25.4,155.5C30.2,172.1 37.8,178.4 50.3,178.4C53.9,178.4 57.9,177.9 62.3,176.9L62.3,176.9C66.7,176.1 71.5,174.8 76.8,173.4L76.8,173.4C78.5,174.8 80.6,175.7 83,175.7C88.2,175.7 92.5,171.4 92.5,166.2C92.5,161 88.2,156.7 83,156.7C78.8,156.7 75.3,159.4 74,163.1L74,163.1C68.7,164.5 64.2,165.7 60.2,166.5L60.2,166.5C56.2,167.3 52.9,167.9 50.1,167.9C42.8,167.9 38.7,164.2 35.4,152.1L35.4,152.1C39.1,149.2 41.5,144.7 41.5,139.5L41.5,117C41.5,110.3 37.4,104.6 31.6,102.2L31.6,102.2C33.7,58.6 75.1,22.3 128,22.3C180.9,22.3 222.3,58.6 224.4,102.2L224.4,102.2C218.6,104.6 214.5,110.3 214.5,117L214.5,139.5C214.5,148.4 221.6,155.5 230.5,155.5L234,155.5C242.8,155.5 250,148.4 250,139.5L250,117C250,110.3 245.8,104.5 239.9,102.2L239.9,102.2C237.7,48.4 187.5,6.9 128,6.9ZM77,43C74.1,44.7 71.4,46.6 68.8,48.6L68.8,48.6C73.3,53.8 79.5,61 83,66.7C88.1,75 92.5,86.6 94.8,92.8C97.2,98.9 97.2,100.5 97.2,103.4C97.2,106.4 93.5,107.4 94.8,110.5C96.2,113.7 101.9,118.4 105.5,122.4C109,126.3 115,131.1 116.2,134.2C117.3,137.4 115,139.7 112.6,141.3C110.2,142.9 103.3,141.5 101.9,143.7C100.6,145.9 104.9,151.4 104.3,154.4C103.8,157 99.7,158.4 98.6,160.7L98.6,160.7C99.1,162 99.4,163.5 99.5,164.9L99.5,164.9C100.7,167 102.3,169.1 101.9,170.9C101.3,173.9 95.2,176.1 94.8,179.2C94.4,182.4 98.2,186.5 99.6,189.9C101,193.2 103.9,196.4 103.1,199.4C102.3,202.3 97.8,205.1 94.8,207.7C91.9,210.2 87.5,211.4 85.4,214.8C83.2,218.1 83,224 81.8,227.8C80.6,231.5 81.2,234.1 78.3,237.3C75.3,240.4 67.6,244.8 64,246.7C60.5,248.7 58.1,248.7 56.9,249.1L199.1,249.1C197.9,248.7 195.5,248.7 192,246.7C188.4,244.8 180.7,240.4 177.7,237.3C174.8,234.1 175.4,231.5 174.2,227.8C173,224 172.8,218.1 170.6,214.8C168.5,211.4 164.1,210.2 161.2,207.7C158.2,205.1 153.7,202.3 152.9,199.4C152.1,196.4 155,193.2 156.4,189.9C157.8,186.5 161.6,182.4 161.2,179.2C160.8,176.1 154.7,173.9 154.1,170.9C153.5,168 158,164.2 157.6,161.5C157.2,158.7 152.3,157.3 151.7,154.4C151.1,151.4 155.4,145.9 154.1,143.7C152.7,141.5 145.8,142.9 143.4,141.3C141,139.7 138.7,137.4 139.8,134.2C141,131.1 147,126.3 150.5,122.4C154.1,118.4 159.8,113.7 161.2,110.5C162.5,107.4 158.8,106.4 158.8,103.4C158.8,100.5 158.8,98.9 161.2,92.8C163.5,86.6 167.9,75 173,66.7C176.5,61 182.7,53.8 187.2,48.6L187.2,48.6C184.6,46.6 181.9,44.7 179,43Z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:type="linear"
|
||||||
|
android:startX="0"
|
||||||
|
android:startY="0"
|
||||||
|
android:endX="154"
|
||||||
|
android:endY="256"
|
||||||
|
android:startColor="#FF4FA3FF"
|
||||||
|
android:endColor="#FF2442B8" />
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
</group>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@android:color/white" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
@@ -35,7 +35,7 @@ public final class DesktopEntry {
|
|||||||
private DesktopEntry() {
|
private DesktopEntry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Call on the event thread once the look-and-feel is installed (the icon uses its accent). */
|
/** Call on the event thread. */
|
||||||
public static void install() {
|
public static void install() {
|
||||||
if (!System.getProperty("os.name", "").toLowerCase(Locale.ROOT).startsWith("linux")
|
if (!System.getProperty("os.name", "").toLowerCase(Locale.ROOT).startsWith("linux")
|
||||||
|| !Boolean.parseBoolean(System.getProperty("ts3j.desktopEntry", "true"))) {
|
|| !Boolean.parseBoolean(System.getProperty("ts3j.desktopEntry", "true"))) {
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public final class IconTheme {
|
|||||||
return c != null ? c : Color.BLACK;
|
return c != null ? c : Color.BLACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BufferedImage rasterize(byte[] data, int size) {
|
static BufferedImage rasterize(byte[] data, int size) {
|
||||||
try {
|
try {
|
||||||
SVGDocument document = new SVGLoader().load(
|
SVGDocument document = new SVGLoader().load(
|
||||||
new ByteArrayInputStream(data), null, LoaderContext.createDefault());
|
new ByteArrayInputStream(data), null, LoaderContext.createDefault());
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -301,8 +303,15 @@ public final class Icons {
|
|||||||
return app(small());
|
return app(small());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Below 32 pixels a variant with a bolder headset, whose thin lines would blur away. */
|
||||||
public static ImageIcon app(int size) {
|
public static ImageIcon app(int size) {
|
||||||
return make(size, Icons::paintApp);
|
String name = size < 32 ? "app-icon-small.svg" : "app-icon.svg";
|
||||||
|
try (InputStream in = Icons.class.getResourceAsStream(name)) {
|
||||||
|
BufferedImage image = IconTheme.rasterize(in.readAllBytes(), size);
|
||||||
|
if (image != null) return new ImageIcon(image);
|
||||||
|
} catch (IOException | RuntimeException ignored) {
|
||||||
|
}
|
||||||
|
return new ImageIcon(new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The window icon at the sizes task bars and switchers pick from. */
|
/** The window icon at the sizes task bars and switchers pick from. */
|
||||||
@@ -475,14 +484,4 @@ public final class Icons {
|
|||||||
g.drawLine(x1, y1, x2, y2);
|
g.drawLine(x1, y1, x2, y2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void paintApp(Graphics2D g) {
|
|
||||||
g.setColor(Theme.accent());
|
|
||||||
g.fillRoundRect(1, 1, 14, 14, 4, 4);
|
|
||||||
g.setColor(Color.WHITE);
|
|
||||||
g.setStroke(new BasicStroke(1.6f));
|
|
||||||
g.drawArc(4, 5, 8, 8, 30, 120);
|
|
||||||
g.drawArc(2, 3, 12, 12, 30, 120);
|
|
||||||
g.fillOval(7, 9, 2, 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import java.awt.BorderLayout;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
import java.awt.KeyboardFocusManager;
|
import java.awt.KeyboardFocusManager;
|
||||||
|
import java.awt.Taskbar;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
@@ -136,6 +137,10 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
|||||||
contacts.addListener(() -> SwingUtilities.invokeLater(this::contactsChanged));
|
contacts.addListener(() -> SwingUtilities.invokeLater(this::contactsChanged));
|
||||||
|
|
||||||
setIconImages(Icons.appImages());
|
setIconImages(Icons.appImages());
|
||||||
|
// The macOS dock ignores window icons.
|
||||||
|
if (Taskbar.isTaskbarSupported() && Taskbar.getTaskbar().isSupported(Taskbar.Feature.ICON_IMAGE)) {
|
||||||
|
Taskbar.getTaskbar().setIconImage(Icons.app(256).getImage());
|
||||||
|
}
|
||||||
// We tear the connections down ourselves on close, so don't let Swing kill the JVM.
|
// We tear the connections down ourselves on close, so don't let Swing kill the JVM.
|
||||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||||
addWindowListener(new WindowAdapter() {
|
addWindowListener(new WindowAdapter() {
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256"><defs><linearGradient id="g" x1="0" y1="0" x2="0.6" y2="1"><stop offset="0" stop-color="#4FA3FF"/><stop offset="1" stop-color="#2442B8"/></linearGradient></defs><path fill="url(#g)" d="M128,5.6C66.1,5.6 11.9,47.6 10.8,104L10.8,104C4.6,107.5 0.5,114.1 0.5,121.7L0.5,146.8C0.5,158.1 9.7,167.3 21,167.3L21.4,167.3C26.9,184.5 36.3,190.5 49.6,190.5C54.3,190.5 59.5,189.7 65.2,188.5L65.2,188.5C68.1,187.8 71.1,187.1 74.3,186.2L74.3,186.2C76.6,187.9 79.4,188.9 82.5,188.9C90,188.9 96.1,182.8 96.1,175.2C96.1,167.7 90,161.6 82.5,161.6C76.9,161.6 72.1,164.9 70,169.7L70,169.7C66.9,170.5 64.1,171.2 61.5,171.8L61.5,171.8C56.5,172.9 52.6,173.6 49.5,173.6C43.5,173.6 40.4,170.9 37.9,163.1L37.9,163.1C42.9,159.4 46,153.4 46,146.8L46,121.7C46,114.2 41.9,107.6 35.8,104L35.8,104C37,65.2 75.7,30.7 128,30.7C180.3,30.7 219,65.2 220.2,104L220.2,104C214.1,107.6 210,114.2 210,121.7L210,146.8C210,158.1 219.1,167.3 230.5,167.3L235,167.3C246.3,167.3 255.5,158.1 255.5,146.8L255.5,121.7C255.5,114.1 251.4,107.5 245.2,104L245.2,104C244.1,47.6 189.9,5.6 128,5.6ZM79.3,52.3C76.4,54 73.7,55.8 71.2,57.7L71.2,57.7C75.5,62.7 81.4,69.6 84.7,75.1C89.7,83 93.8,94.2 96.1,100.1C98.4,106 98.4,107.5 98.4,110.4C98.4,113.2 94.8,114.1 96.1,117.2C97.5,120.2 103,124.8 106.4,128.6C109.8,132.4 115.5,136.9 116.6,140C117.8,143 115.5,145.3 113.2,146.8C110.9,148.3 104.3,147 103,149.1C101.6,151.1 105.8,156.5 105.2,159.3C104.9,160.9 103.2,162 101.8,163.2L101.8,163.2C104,166.7 105.2,170.8 105.2,175.2C105.2,175.2 105.2,175.2 105.2,175.2C105.2,181.2 102.9,186.6 99.2,190.7L99.2,190.7C99.8,191.6 100.3,192.6 100.7,193.5C102,196.7 104.9,199.7 104.1,202.6C103.3,205.4 99,208.1 96.1,210.5C93.3,213 89.1,214.1 87,217.4C84.9,220.6 84.7,226.3 83.6,229.9C82.5,233.5 83,236 80.2,239C77.3,242 69.9,246.2 66.5,248.1C63.1,250 60.8,250 59.7,250.4L196.3,250.4C195.2,250 192.9,250 189.5,248.1C186.1,246.2 178.7,242 175.8,239C173,236 173.5,233.5 172.4,229.9C171.3,226.3 171.1,220.6 169,217.4C166.9,214.1 162.7,213 159.9,210.5C157,208.1 152.7,205.4 151.9,202.6C151.1,199.7 154,196.7 155.3,193.5C156.6,190.2 160.3,186.2 159.9,183.2C159.5,180.2 153.6,178.1 153,175.2C152.5,172.4 156.8,168.8 156.5,166.1C156.1,163.5 151.3,162.2 150.8,159.3C150.2,156.5 154.4,151.1 153,149.1C151.7,147 145.1,148.3 142.8,146.8C140.5,145.3 138.2,143 139.4,140C140.5,136.9 146.2,132.4 149.6,128.6C153,124.8 158.5,120.2 159.9,117.2C161.2,114.1 157.6,113.2 157.6,110.4C157.6,107.5 157.6,106 159.9,100.1C162.2,94.2 166.3,83 171.3,75.1C174.6,69.6 180.5,62.7 184.8,57.7L184.8,57.7C182.3,55.8 179.6,54 176.7,52.3Z"/></svg>
|
||||||
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256"><defs><linearGradient id="g" x1="0" y1="0" x2="0.6" y2="1"><stop offset="0" stop-color="#4FA3FF"/><stop offset="1" stop-color="#2442B8"/></linearGradient></defs><path fill="url(#g)" d="M128,6.9C68.5,6.9 18.3,48.4 16.1,102.2L16.1,102.2C10.2,104.5 6,110.3 6,117L6,139.5C6,148.4 13.2,155.5 22,155.5L25.4,155.5C30.2,172.1 37.8,178.4 50.3,178.4C53.9,178.4 57.9,177.9 62.3,176.9L62.3,176.9C66.7,176.1 71.5,174.8 76.8,173.4L76.8,173.4C78.5,174.8 80.6,175.7 83,175.7C88.2,175.7 92.5,171.4 92.5,166.2C92.5,161 88.2,156.7 83,156.7C78.8,156.7 75.3,159.4 74,163.1L74,163.1C68.7,164.5 64.2,165.7 60.2,166.5L60.2,166.5C56.2,167.3 52.9,167.9 50.1,167.9C42.8,167.9 38.7,164.2 35.4,152.1L35.4,152.1C39.1,149.2 41.5,144.7 41.5,139.5L41.5,117C41.5,110.3 37.4,104.6 31.6,102.2L31.6,102.2C33.7,58.6 75.1,22.3 128,22.3C180.9,22.3 222.3,58.6 224.4,102.2L224.4,102.2C218.6,104.6 214.5,110.3 214.5,117L214.5,139.5C214.5,148.4 221.6,155.5 230.5,155.5L234,155.5C242.8,155.5 250,148.4 250,139.5L250,117C250,110.3 245.8,104.5 239.9,102.2L239.9,102.2C237.7,48.4 187.5,6.9 128,6.9ZM77,43C74.1,44.7 71.4,46.6 68.8,48.6L68.8,48.6C73.3,53.8 79.5,61 83,66.7C88.1,75 92.5,86.6 94.8,92.8C97.2,98.9 97.2,100.5 97.2,103.4C97.2,106.4 93.5,107.4 94.8,110.5C96.2,113.7 101.9,118.4 105.5,122.4C109,126.3 115,131.1 116.2,134.2C117.3,137.4 115,139.7 112.6,141.3C110.2,142.9 103.3,141.5 101.9,143.7C100.6,145.9 104.9,151.4 104.3,154.4C103.8,157 99.7,158.4 98.6,160.7L98.6,160.7C99.1,162 99.4,163.5 99.5,164.9L99.5,164.9C100.7,167 102.3,169.1 101.9,170.9C101.3,173.9 95.2,176.1 94.8,179.2C94.4,182.4 98.2,186.5 99.6,189.9C101,193.2 103.9,196.4 103.1,199.4C102.3,202.3 97.8,205.1 94.8,207.7C91.9,210.2 87.5,211.4 85.4,214.8C83.2,218.1 83,224 81.8,227.8C80.6,231.5 81.2,234.1 78.3,237.3C75.3,240.4 67.6,244.8 64,246.7C60.5,248.7 58.1,248.7 56.9,249.1L199.1,249.1C197.9,248.7 195.5,248.7 192,246.7C188.4,244.8 180.7,240.4 177.7,237.3C174.8,234.1 175.4,231.5 174.2,227.8C173,224 172.8,218.1 170.6,214.8C168.5,211.4 164.1,210.2 161.2,207.7C158.2,205.1 153.7,202.3 152.9,199.4C152.1,196.4 155,193.2 156.4,189.9C157.8,186.5 161.6,182.4 161.2,179.2C160.8,176.1 154.7,173.9 154.1,170.9C153.5,168 158,164.2 157.6,161.5C157.2,158.7 152.3,157.3 151.7,154.4C151.1,151.4 155.4,145.9 154.1,143.7C152.7,141.5 145.8,142.9 143.4,141.3C141,139.7 138.7,137.4 139.8,134.2C141,131.1 147,126.3 150.5,122.4C154.1,118.4 159.8,113.7 161.2,110.5C162.5,107.4 158.8,106.4 158.8,103.4C158.8,100.5 158.8,98.9 161.2,92.8C163.5,86.6 167.9,75 173,66.7C176.5,61 182.7,53.8 187.2,48.6L187.2,48.6C184.6,46.6 181.9,44.7 179,43Z"/></svg>
|
||||||
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,180 @@
|
|||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Shape;
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
import java.awt.geom.Arc2D;
|
||||||
|
import java.awt.geom.Area;
|
||||||
|
import java.awt.geom.Ellipse2D;
|
||||||
|
import java.awt.geom.Path2D;
|
||||||
|
import java.awt.geom.PathIterator;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws the application icon: Rubin's vase, whose outline is two faces looking at each
|
||||||
|
* other, wearing one headset — the left face talks into its microphone. Writes the
|
||||||
|
* desktop's SVGs and the Android launcher's foreground.
|
||||||
|
*
|
||||||
|
* <p>Run from the repository root: {@code java ts3-client/tools/AppIcon.java}.
|
||||||
|
*/
|
||||||
|
public class AppIcon {
|
||||||
|
|
||||||
|
/** The left face, top to bottom, in a 256 box; the vase is it and its mirror image. */
|
||||||
|
static final double[][] PROFILE = {
|
||||||
|
{74, 52}, {90, 72}, {100, 94}, {102, 103}, {100, 109}, {109, 119}, {118, 129},
|
||||||
|
{115, 135}, {106, 137}, {108, 146}, {103, 152}, {106, 160}, {100, 167}, {104, 176},
|
||||||
|
{107, 184}, {100, 191}, {92, 197}, {89, 208}, {86, 216}, {74, 224}, {68, 226}};
|
||||||
|
|
||||||
|
static final String LIGHT = "4FA3FF";
|
||||||
|
static final String DARK = "2442B8";
|
||||||
|
|
||||||
|
/** Headset geometry; the small icon gets a bolder one. */
|
||||||
|
record Headset(double earX, double earY, double cupW, double cupH, double band, double bandTop,
|
||||||
|
double boom, double micX, double micY, double mic, double gap) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static final Headset LARGE = new Headset(40, 124, 30, 46, 13, 28, 9, 90, 156, 8, 6);
|
||||||
|
static final Headset SMALL = new Headset(36, 124, 40, 58, 22, 22, 15, 88, 160, 12, 8);
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
Path root = Path.of("");
|
||||||
|
Path ui = root.resolve("ts3-client/swing/src/main/resources/com/ts3client/ui");
|
||||||
|
Files.writeString(ui.resolve("app-icon.svg"), svg(path(icon(LARGE), 6)));
|
||||||
|
Files.writeString(ui.resolve("app-icon-small.svg"), svg(path(icon(SMALL), 0.5)));
|
||||||
|
Files.writeString(root.resolve("android/app/src/main/res/drawable/ic_launcher_foreground.xml"),
|
||||||
|
vector(path(icon(LARGE), 6)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The vase with the headset, which a gap keeps apart from it. */
|
||||||
|
static Area icon(Headset h) {
|
||||||
|
Path2D outline = new Path2D.Double();
|
||||||
|
outline.moveTo(PROFILE[0][0], PROFILE[0][1]);
|
||||||
|
spline(outline, PROFILE);
|
||||||
|
double[][] right = new double[PROFILE.length][];
|
||||||
|
for (int i = 0; i < PROFILE.length; i++) {
|
||||||
|
double[] p = PROFILE[PROFILE.length - 1 - i];
|
||||||
|
right[i] = new double[]{256 - p[0], p[1]};
|
||||||
|
}
|
||||||
|
outline.lineTo(right[0][0], right[0][1]);
|
||||||
|
spline(outline, right);
|
||||||
|
outline.closePath();
|
||||||
|
|
||||||
|
Area set = new Area();
|
||||||
|
set.add(new Area(cup(h.earX(), h)));
|
||||||
|
set.add(new Area(cup(256 - h.earX(), h)));
|
||||||
|
double r = 128 - h.earX(), bandBottom = h.earY() - h.cupH() / 2 + 4;
|
||||||
|
set.add(stroke(new Arc2D.Double(h.earX(), h.bandTop(), 2 * r, 2 * (bandBottom - h.bandTop()),
|
||||||
|
0, 180, Arc2D.OPEN), h.band()));
|
||||||
|
Path2D boom = new Path2D.Double();
|
||||||
|
boom.moveTo(h.earX() + 4, h.earY() + h.cupH() / 2 - 8);
|
||||||
|
boom.curveTo(h.earX() + 10, h.micY() + 12, h.micX() - 30, h.micY() + 8, h.micX(), h.micY());
|
||||||
|
set.add(stroke(boom, h.boom()));
|
||||||
|
set.add(new Area(new Ellipse2D.Double(h.micX() - h.mic(), h.micY() - h.mic(), 2 * h.mic(), 2 * h.mic())));
|
||||||
|
|
||||||
|
Area icon = new Area(outline);
|
||||||
|
icon.subtract(stroke(set, 2 * h.gap()));
|
||||||
|
icon.add(set);
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Shape cup(double x, Headset h) {
|
||||||
|
return new RoundRectangle2D.Double(x - h.cupW() / 2, h.earY() - h.cupH() / 2, h.cupW(), h.cupH(),
|
||||||
|
h.cupW() * 0.9, h.cupW() * 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Catmull-Rom through the points; the path is already at the first. */
|
||||||
|
static void spline(Path2D path, double[][] pts) {
|
||||||
|
for (int i = 0; i < pts.length - 1; i++) {
|
||||||
|
double[] p0 = pts[Math.max(i - 1, 0)], p1 = pts[i], p2 = pts[i + 1], p3 = pts[Math.min(i + 2, pts.length - 1)];
|
||||||
|
path.curveTo(p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6,
|
||||||
|
p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6, p2[0], p2[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Area stroke(Shape shape, double width) {
|
||||||
|
return new Area(new BasicStroke((float) width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)
|
||||||
|
.createStrokedShape(shape));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Path data of the shape scaled to fill the 256 box, less a margin. */
|
||||||
|
static String path(Area shape, double margin) {
|
||||||
|
Rectangle2D b = shape.getBounds2D();
|
||||||
|
double k = (256 - 2 * margin) / Math.max(b.getWidth(), b.getHeight());
|
||||||
|
AffineTransform t = new AffineTransform();
|
||||||
|
t.translate(128, 128);
|
||||||
|
t.scale(k, k);
|
||||||
|
t.translate(-b.getCenterX(), -b.getCenterY());
|
||||||
|
StringBuilder s = new StringBuilder();
|
||||||
|
double[] c = new double[6];
|
||||||
|
for (PathIterator it = shape.getPathIterator(t); !it.isDone(); it.next()) {
|
||||||
|
int type = it.currentSegment(c);
|
||||||
|
switch (type) {
|
||||||
|
case PathIterator.SEG_MOVETO -> s.append('M').append(points(c, 1));
|
||||||
|
case PathIterator.SEG_LINETO -> s.append('L').append(points(c, 1));
|
||||||
|
case PathIterator.SEG_QUADTO -> s.append('Q').append(points(c, 2));
|
||||||
|
case PathIterator.SEG_CUBICTO -> s.append('C').append(points(c, 3));
|
||||||
|
case PathIterator.SEG_CLOSE -> s.append('Z');
|
||||||
|
default -> throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
static String points(double[] c, int n) {
|
||||||
|
StringBuilder s = new StringBuilder();
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
if (i > 0) s.append(' ');
|
||||||
|
s.append(number(c[2 * i])).append(',').append(number(c[2 * i + 1]));
|
||||||
|
}
|
||||||
|
return s.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
static String number(double v) {
|
||||||
|
String s = String.format(Locale.ROOT, "%.1f", v);
|
||||||
|
return s.endsWith(".0") ? s.substring(0, s.length() - 2) : s;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String svg(String path) {
|
||||||
|
return """
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256">\
|
||||||
|
<defs><linearGradient id="g" x1="0" y1="0" x2="0.6" y2="1">\
|
||||||
|
<stop offset="0" stop-color="#%s"/><stop offset="1" stop-color="#%s"/></linearGradient></defs>\
|
||||||
|
<path fill="url(#g)" d="%s"/></svg>
|
||||||
|
""".formatted(LIGHT, DARK, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static String vector(String path) {
|
||||||
|
return """
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generated by ts3-client/tools/AppIcon.java; the art sits in the adaptive icon's safe zone. -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="256"
|
||||||
|
android:viewportHeight="256">
|
||||||
|
<group
|
||||||
|
android:scaleX="0.62"
|
||||||
|
android:scaleY="0.62"
|
||||||
|
android:pivotX="128"
|
||||||
|
android:pivotY="128">
|
||||||
|
<path android:pathData="%s">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:type="linear"
|
||||||
|
android:startX="0"
|
||||||
|
android:startY="0"
|
||||||
|
android:endX="154"
|
||||||
|
android:endY="256"
|
||||||
|
android:startColor="#FF%s"
|
||||||
|
android:endColor="#FF%s" />
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
</group>
|
||||||
|
</vector>
|
||||||
|
""".formatted(path, LIGHT, DARK);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user