feat(brand): app icon painter + generated 1024px icon PNGs

Introduces AppIconMark (navy gradient field + 2×2 glossy blocks reusing
paintGlossyTile) and a testWidgets generator that writes icon.png,
icon_background.png, and icon_foreground.png to assets/icon/ for the
upcoming flutter_launcher_icons task.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 18:06:18 +09:00
parent 498fb6af83
commit 099ced377d
5 changed files with 89 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
// test/tool/generate_brand_assets_test.dart
import 'dart:io';
import 'dart:ui';
import 'package:block_seasons/ui/branding/app_icon_painter.dart';
import 'package:flutter_test/flutter_test.dart';
Future<void> _writePng(String path, int size, void Function(Canvas) draw) async {
final recorder = PictureRecorder();
final canvas = Canvas(recorder);
draw(canvas);
final picture = recorder.endRecording();
final image = await picture.toImage(size, size);
final bytes = await image.toByteData(format: ImageByteFormat.png);
File(path).parent.createSync(recursive: true);
File(path).writeAsBytesSync(bytes!.buffer.asUint8List());
}
void main() {
testWidgets('generate launcher icon PNGs', (tester) async {
const s = 1024;
final full = Rect.fromLTWH(0, 0, s.toDouble(), s.toDouble());
await tester.runAsync(() async {
// Master (iOS + fallback): opaque navy + blocks at 60%.
await _writePng('assets/icon/icon.png', s, (c) {
AppIconMark.paintBackground(c, full);
AppIconMark.paintBlocks(c, s.toDouble(), groupFraction: 0.6);
});
// Adaptive background: navy only.
await _writePng('assets/icon/icon_background.png', s, (c) {
AppIconMark.paintBackground(c, full);
});
// Adaptive foreground: blocks only (transparent), 52% for the safe zone.
await _writePng('assets/icon/icon_foreground.png', s, (c) {
AppIconMark.paintBlocks(c, s.toDouble(), groupFraction: 0.52);
});
});
for (final f in ['icon.png', 'icon_background.png', 'icon_foreground.png']) {
expect(File('assets/icon/$f').existsSync(), isTrue, reason: f);
}
});
}