Skip to content

ProCraft for Android: An Android native painting app written in Rust

Rust

feat(app): a new app icon, a paintbrush in a warm-to-cool blend on black

Joshfd5b45d45225
diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GalleryScreen.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GalleryScreen.kt
index b2735e8..5bd5ad1 100644
--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GalleryScreen.kt
+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GalleryScreen.kt
@@ -1493,7 +1493,7 @@ private fun AboutApp(onClose: () -> Unit) {
// the launcher icon: its field, and its picture drawn at the adaptive icon's full size
Box(Modifier.size(300.dp).clip(RoundedCornerShape(67.dp)).background(AboutIconField), contentAlignment = Alignment.Center) {
androidx.compose.foundation.Image(
- androidx.compose.ui.res.painterResource(io.github.artcraftandroid.procraft.R.drawable.ic_launcher_foreground),
+ androidx.compose.ui.res.painterResource(io.github.artcraftandroid.procraft.R.drawable.procraft_mark),
contentDescription = null,
modifier = Modifier.requiredSize(450.dp),
)
@@ -1517,7 +1517,7 @@ private fun AboutApp(onClose: () -> Unit) {
// as measured: the gallery under a near-black veil, the light round close button
private val AboutVeil = Color(0xD90B0B0B)
-private val AboutIconField = Color(0xFF1C1C1E)
+private val AboutIconField = Color(0xFF0B0B0C)
private val AboutInk = Color(0xFFBDBDBD)
private val AboutClose = Color(0xFFE3E3E3)
private val AboutCloseInk = Color(0xFF1C1C1C)
diff --git a/apps/procraft-android/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png b/apps/procraft-android/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..5cf2280
Binary files /dev/null and b/apps/procraft-android/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png differ
diff --git a/apps/procraft-android/android/app/src/main/res/drawable-hdpi/ic_launcher_monochrome.png b/apps/procraft-android/android/app/src/main/res/drawable-hdpi/ic_launcher_monochrome.png
new file mode 100644
index 0000000..67f4521
Binary files /dev/null and b/apps/procraft-android/android/app/src/main/res/drawable-hdpi/ic_launcher_monochrome.png differ
diff --git a/apps/procraft-android/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png b/apps/procraft-android/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..e6350db
Binary files /dev/null and b/apps/procraft-android/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png differ
diff --git a/apps/procraft-android/android/app/src/main/res/drawable-mdpi/ic_launcher_monochrome.png b/apps/procraft-android/android/app/src/main/res/drawable-mdpi/ic_launcher_monochrome.png
new file mode 100644
index 0000000..e7f6f98
Binary files /dev/null and b/apps/procraft-android/android/app/src/main/res/drawable-mdpi/ic_launcher_monochrome.png differ
diff --git a/apps/procraft-android/android/app/src/main/res/drawable-nodpi/procraft_mark.png b/apps/procraft-android/android/app/src/main/res/drawable-nodpi/procraft_mark.png
new file mode 100644
index 0000000..4b0895c
Binary files /dev/null and b/apps/procraft-android/android/app/src/main/res/drawable-nodpi/procraft_mark.png differ
diff --git a/apps/procraft-android/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png b/apps/procraft-android/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..44804b5
Binary files /dev/null and b/apps/procraft-android/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png differ
diff --git a/apps/procraft-android/android/app/src/main/res/drawable-xhdpi/ic_launcher_monochrome.png b/apps/procraft-android/android/app/src/main/res/drawable-xhdpi/ic_launcher_monochrome.png
new file mode 100644
index 0000000..d6fd91a
Binary files /dev/null and b/apps/procraft-android/android/app/src/main/res/drawable-xhdpi/ic_launcher_monochrome.png differ
diff --git a/apps/procraft-android/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png b/apps/procraft-android/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..c4bf007
Binary files /dev/null and b/apps/procraft-android/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png differ
diff --git a/apps/procraft-android/android/app/src/main/res/drawable-xxhdpi/ic_launcher_monochrome.png b/apps/procraft-android/android/app/src/main/res/drawable-xxhdpi/ic_launcher_monochrome.png
new file mode 100644
index 0000000..7db558b
Binary files /dev/null and b/apps/procraft-android/android/app/src/main/res/drawable-xxhdpi/ic_launcher_monochrome.png differ
diff --git a/apps/procraft-android/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png b/apps/procraft-android/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..f67fc9d
Binary files /dev/null and b/apps/procraft-android/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png differ
diff --git a/apps/procraft-android/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_monochrome.png b/apps/procraft-android/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_monochrome.png
new file mode 100644
index 0000000..b292d78
Binary files /dev/null and b/apps/procraft-android/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_monochrome.png differ
diff --git a/apps/procraft-android/android/app/src/main/res/drawable/ic_launcher_foreground.xml b/apps/procraft-android/android/app/src/main/res/drawable/ic_launcher_foreground.xml
deleted file mode 100644
index 8f9eca1..0000000
--- a/apps/procraft-android/android/app/src/main/res/drawable/ic_launcher_foreground.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="108dp"
- android:height="108dp"
- android:viewportWidth="108"
- android:viewportHeight="108">
- <!-- a tapered stroke -->
- <path
- android:fillColor="#FFFFFFFF"
- android:pathData="M34,72 C42,58 54,46 72,36 C74,35 75,37 73,38 C58,49 47,61 39,74 C37,77 32,76 34,72 Z" />
- <path
- android:fillColor="#FF4F9DFF"
- android:pathData="M31,79 a4,4 0 1,0 8,0 a4,4 0 1,0 -8,0" />
-</vector>
diff --git a/apps/procraft-android/android/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/apps/procraft-android/android/app/src/main/res/mipmap-anydpi/ic_launcher.xml
index ff89aa7..81c6dae 100644
--- a/apps/procraft-android/android/app/src/main/res/mipmap-anydpi/ic_launcher.xml
+++ b/apps/procraft-android/android/app/src/main/res/mipmap-anydpi/ic_launcher.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- A placeholder icon of our own (a brush stroke on a dark field) until ProCraft has its icon. -->
+<!-- ProCraft's icon: a paintbrush in a warm-to-cool blend on black (tools/app-icon/make_icon.py). -->
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
+ <monochrome android:drawable="@drawable/ic_launcher_monochrome" />
</adaptive-icon>
diff --git a/apps/procraft-android/android/app/src/main/res/values/themes.xml b/apps/procraft-android/android/app/src/main/res/values/themes.xml
index 4dec5be..ee55141 100644
--- a/apps/procraft-android/android/app/src/main/res/values/themes.xml
+++ b/apps/procraft-android/android/app/src/main/res/values/themes.xml
@@ -2,7 +2,7 @@
<resources>
<!-- dark, so nothing flashes before the first frame -->
<color name="window_background">#FF000000</color>
- <color name="ic_launcher_background">#FF1C1C1E</color>
+ <color name="ic_launcher_background">#FF0B0B0C</color>
<style name="Theme.ProCraft" parent="android:Theme.Material.NoActionBar">
<item name="android:windowBackground">@color/window_background</item>
diff --git a/assets/app-icon/README.md b/assets/app-icon/README.md
new file mode 100644
index 0000000..6e933d1
--- /dev/null
+++ b/assets/app-icon/README.md
@@ -0,0 +1,44 @@
+# ProCraft app icon
+
+<img src="procraft-512.png" alt="ProCraft app icon: a paintbrush in a warm-to-cool blend on black" width="128">
+
+A paintbrush, writing down to the left: a tapered handle in a warm-to-cool blend, a metal ferrule,
+paper bristles with a tip dipped in the blend, and a soft glow of the blend, on a black tile.
+
+## Palette
+
+| Colour | Hex | Used for |
+|---|---|---|
+| Ink | `#0b0b0c` | the tile (the launcher's background layer) |
+| Paper | `#efe9dc` | the bristles |
+| Metal | `#c4c6ce`, line `#787a82` | the ferrule |
+| The blend | `#ffc43d` → `#f07a2e` → `#ec4878` → `#8b5cf6` → `#3b82f6` | the handle, the dipped tip, the glow |
+
+## Geometry
+
+A 512-unit tile, a rounded square with `rx=112` (drawn at 2048 px and shrunk). On Android the
+tile is the adaptive icon's middle 72 of 108 dp: the background layer is the ink, the
+foreground the brush and its glow, the monochrome layer the brush alone (for themed icons).
+
+## Provenance
+
+Original work, drawn in code by `tools/app-icon/make_icon.py` (Pillow), which writes every size
+below. MIT OR Apache-2.0, like the code.
+
+## Files
+
+| File | What |
+|---|---|
+| `procraft-1024.png`, `procraft-512.png` | the icon on its rounded tile (store listing, README) |
+| `res/drawable-*dpi/ic_launcher_foreground.png` | the adaptive icon's foreground, 108 dp |
+| `res/drawable-*dpi/ic_launcher_monochrome.png` | its monochrome layer, for themed icons |
+| `res/drawable-nodpi/procraft_mark.png` | the foreground at 1350 px, for the About screen |
+| `res/mipmap-anydpi/ic_launcher.xml` | the adaptive icon (background `@color/ic_launcher_background`) |
+
+The `res/` paths are under `apps/procraft-android/android/app/src/main/`.
+
+## Regenerate
+
+```
+python tools/app-icon/make_icon.py
+```
diff --git a/assets/app-icon/procraft-1024.png b/assets/app-icon/procraft-1024.png
new file mode 100644
index 0000000..9e32229
Binary files /dev/null and b/assets/app-icon/procraft-1024.png differ
diff --git a/assets/app-icon/procraft-512.png b/assets/app-icon/procraft-512.png
new file mode 100644
index 0000000..0bc07cc
Binary files /dev/null and b/assets/app-icon/procraft-512.png differ
diff --git a/tools/app-icon/make_icon.py b/tools/app-icon/make_icon.py
new file mode 100644
index 0000000..8441f67
--- /dev/null
+++ b/tools/app-icon/make_icon.py
@@ -0,0 +1,140 @@
+"""Draws ProCraft's app icon, a paintbrush in a warm-to-cool blend on black, and writes every size
+the app and the repository use. Needs Pillow. Run from anywhere:
+
+ python tools/app-icon/make_icon.py
+
+Writes:
+- assets/app-icon/procraft-1024.png, procraft-512.png: the icon on its rounded tile.
+- the Android adaptive icon's layers (108 dp, the tile its middle 72 dp): the brush and its glow
+ (drawable-*dpi/ic_launcher_foreground.png), the brush alone in white for themed icons
+ (drawable-*dpi/ic_launcher_monochrome.png), and a large copy for the About screen
+ (drawable-nodpi/procraft_mark.png).
+"""
+
+import math
+import os
+
+from PIL import Image, ImageChops, ImageDraw, ImageFilter
+
+ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+RES = os.path.join(ROOT, 'apps', 'procraft-android', 'android', 'app', 'src', 'main', 'res')
+
+S = 2048 # the 512-unit tile, drawn at 4x
+INK = (11, 11, 12)
+PAPER = (239, 233, 220)
+METAL = (196, 198, 206)
+METAL_LINE = (120, 122, 130)
+# the blend: amber, orange, coral pink, violet, blue
+STOPS = [(0.0, (255, 196, 61)), (0.28, (240, 122, 46)), (0.52, (236, 72, 120)), (0.76, (139, 92, 246)),
+ (1.0, (59, 130, 246))]
+ANGLE = 225 # the brush drawn along x, then turned so it writes down to the left
+
+
+def blend(t):
+ t = min(1.0, max(0.0, t))
+ for (a, ca), (b, cb) in zip(STOPS, STOPS[1:]):
+ if t <= b:
+ u = (t - a) / (b - a)
+ return tuple(round(ca[i] + (cb[i] - ca[i]) * u) for i in range(3))
+ return STOPS[-1][1]
+
+
+def gradient_along(x0, x1):
+ """An S x S picture whose colour runs along x, from the blend's start at x0 to its end at x1."""
+ row = Image.new('RGB', (S, 1))
+ for x in range(S):
+ row.putpixel((x, 0), blend((x - x0) / (x1 - x0)))
+ return row.resize((S, S), Image.NEAREST)
+
+
+def brush():
+ """The paintbrush along x: a tapered handle in the blend, a metal ferrule, paper bristles whose
+ tip is dipped in the blend."""
+ layer = Image.new('RGBA', (S, S), (0, 0, 0, 0))
+ cy = S / 2
+ x_end, x_ferrule, x_bristle, x_tip = 230, 1080, 1300, 1820
+ handle = [(x_end + 60, cy - 70), (x_ferrule - 260, cy - 120), (x_ferrule, cy - 100),
+ (x_ferrule, cy + 100), (x_ferrule - 260, cy + 120), (x_end + 60, cy + 70)]
+ m = Image.new('L', (S, S), 0)
+ md = ImageDraw.Draw(m)
+ md.polygon(handle, fill=255)
+ md.ellipse((x_end, cy - 70, x_end + 120, cy + 70), fill=255)
+ layer.paste(gradient_along(x_end, x_ferrule), (0, 0), m)
+ shine = Image.new('RGBA', (S, S), (0, 0, 0, 0))
+ ImageDraw.Draw(shine).polygon([(x_end + 60, cy - 70), (x_ferrule - 260, cy - 120), (x_ferrule, cy - 100),
+ (x_ferrule, cy - 60), (x_end + 60, cy - 40)], fill=(255, 255, 255, 52))
+ layer.alpha_composite(shine)
+ d = ImageDraw.Draw(layer)
+ d.polygon([(x_ferrule, cy - 104), (x_bristle, cy - 128), (x_bristle, cy + 128), (x_ferrule, cy + 104)],
+ fill=METAL + (255,))
+ d.line((x_ferrule + 70, cy - 112, x_ferrule + 70, cy + 112), fill=METAL_LINE + (255,), width=14)
+ bristles = [(x_bristle, cy - 128)]
+ for i in range(1, 41):
+ t = i / 40
+ x = x_bristle + t * (x_tip - x_bristle)
+ y = cy - 128 * (1 - t ** 1.6) * (1 + 0.25 * math.sin(t * math.pi))
+ bristles.append((x, y))
+ bristles += [(x, 2 * cy - y) for x, y in reversed(bristles)]
+ d.polygon(bristles, fill=PAPER + (255,))
+ dip = Image.new('L', (S, S), 0)
+ ImageDraw.Draw(dip).polygon(bristles, fill=255)
+ cut = Image.new('L', (S, S), 0)
+ ImageDraw.Draw(cut).rectangle((x_bristle + 0.55 * (x_tip - x_bristle), 0, S, S), fill=255)
+ layer.paste(gradient_along(x_bristle + 0.4 * (x_tip - x_bristle), x_tip + 200), (0, 0), ImageChops.multiply(dip, cut))
+ return layer.rotate(ANGLE, resample=Image.BICUBIC, center=(S / 2, S / 2))
+
+
+def glow(turned):
+ """A soft glow of the blend around the turned brush."""
+ alpha = turned.split()[3].filter(ImageFilter.GaussianBlur(60)).point(lambda a: a * 0.35)
+ colour = gradient_along(S * 0.15, S * 0.85).rotate(ANGLE, center=(S / 2, S / 2))
+ out = Image.new('RGBA', (S, S), (0, 0, 0, 0))
+ out.paste(colour, (0, 0), alpha)
+ return out
+
+
+def tile_mask():
+ m = Image.new('L', (S, S), 0)
+ ImageDraw.Draw(m).rounded_rectangle((0, 0, S - 1, S - 1), radius=112 * 4, fill=255)
+ return m
+
+
+def adaptive(picture):
+ """`picture` (the tile's contents) placed in the middle 72 of the adaptive icon's 108."""
+ side = round(S * 108 / 72)
+ out = Image.new('RGBA', (side, side), (0, 0, 0, 0))
+ out.alpha_composite(picture, ((side - S) // 2, (side - S) // 2))
+ return out
+
+
+def save(image, path, size):
+ os.makedirs(os.path.dirname(path), exist_ok=True)
+ image.resize((size, size), Image.LANCZOS).save(path, optimize=True)
+
+
+def main():
+ turned = brush()
+ picture = glow(turned)
+ picture.alpha_composite(turned)
+
+ tile = Image.new('RGBA', (S, S), INK + (255,))
+ tile.alpha_composite(picture)
+ tile.putalpha(tile_mask())
+ for size in (1024, 512):
+ save(tile, os.path.join(ROOT, 'assets', 'app-icon', f'procraft-{size}.png'), size)
+
+ foreground = adaptive(picture)
+ mono = Image.new('RGBA', turned.size, (255, 255, 255, 0))
+ mono.putalpha(turned.split()[3])
+ monochrome = adaptive(mono)
+ for bucket, scale in (('mdpi', 1), ('hdpi', 1.5), ('xhdpi', 2), ('xxhdpi', 3), ('xxxhdpi', 4)):
+ size = round(108 * scale)
+ save(foreground, os.path.join(RES, f'drawable-{bucket}', 'ic_launcher_foreground.png'), size)
+ save(monochrome, os.path.join(RES, f'drawable-{bucket}', 'ic_launcher_monochrome.png'), size)
+ # the About screen shows it 450 dp across: sharp up to about 3 pixels a dp
+ save(foreground, os.path.join(RES, 'drawable-nodpi', 'procraft_mark.png'), 1350)
+ print('written')
+
+
+if __name__ == '__main__':
+ main()