Files
desktop-plugin/tool/make_test_card.dart
T
dzc 689a07ca44 feat: 饭卡打印助手 Flutter 版(Phase 1/2:协议服务器 + macOS CUPS 真机打印)
- 协议与 C# 版 card-printer-agent 逐字段对齐(38200-38202 顺延、CORS *、串行任务队列、30 分钟保留)
- macOS CUPS 后端:lpoptions 队列发现 + lp 参数列表提交(LC_ALL=C 防本地化粘连坑)
- --mock 模拟模式 + bin/agent.dart headless 入口 + 测试卡生成工具
- 真机验收:HiTi CS-200e status 就绪 + 真实出卡;macOS 通用二进制构建通过
- App Sandbox 已关闭(服务需绑回环端口并调用 lp 子进程);zaxprint URL scheme 已注册
2026-09-21 12:03:27 +08:00

39 lines
1.5 KiB
Dart

// 生成 1014×642 测试卡 PNG(真实打印验收用),默认输出 build/test_card.png
// dart run tool/make_test_card.dart [输出路径]
import 'dart:io';
import 'package:image/image.dart';
Future<void> main(List<String> args) async {
final img = Image(width: 1014, height: 642);
fill(img, color: ColorRgb8(255, 255, 255));
// 边框
drawRect(img, x1: 8, y1: 8, x2: 1005, y2: 633, color: ColorRgb8(0, 120, 215));
// CMYK 色块:验证四色分色与套印
fillRect(img, x1: 60, y1: 60, x2: 300, y2: 300, color: ColorRgb8(0, 174, 239));
fillRect(img, x1: 320, y1: 60, x2: 560, y2: 300, color: ColorRgb8(236, 0, 140));
fillRect(img, x1: 580, y1: 60, x2: 820, y2: 300, color: ColorRgb8(255, 221, 0));
fillRect(img, x1: 840, y1: 60, x2: 960, y2: 300, color: ColorRgb8(0, 0, 0));
drawString(img, 'DESKTOP-PLUGIN TEST CARD', font: arial24, x: 60, y: 360, color: ColorRgb8(20, 20, 20));
drawString(
img,
'flutter print verify ${DateTime.now().toIso8601String().substring(0, 19)}',
font: arial14,
x: 60,
y: 420,
color: ColorRgb8(90, 90, 90),
);
drawString(img, '127.0.0.1:38200 /api/card-printer/print', font: arial14, x: 60, y: 450, color: ColorRgb8(90, 90, 90));
final png = encodePng(img);
final out = args.isNotEmpty ? args.first : 'build/test_card.png';
final file = File(out);
await file.parent.create(recursive: true);
await file.writeAsBytes(png);
// ignore: avoid_print
print('written $out (${png.length} bytes)');
}