85 lines
2.3 KiB
Dart
85 lines
2.3 KiB
Dart
|
|
/// 导出画布的共享几何约束:固定 1920×1080、2 倍像素比、内容区与
|
||
|
|
/// 缩放/平移结果 [ExportFit]。
|
||
|
|
///
|
||
|
|
/// 架构位置:`lib/export/` 为共享导出层,不依赖任何具体模块;时序图与
|
||
|
|
/// 架构图模块各自的导出逻辑都复用这里的常量与 [ExportFit]。
|
||
|
|
library;
|
||
|
|
|
||
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
import 'package:sequence_diagram/theme/tokens.dart';
|
||
|
|
|
||
|
|
/// 导出画布尺寸(固定逻辑尺寸)。
|
||
|
|
const Size kExportSize = Size(1920, 1080);
|
||
|
|
|
||
|
|
/// 导出渲染像素比:按 2 倍渲染成 3840×2160,保证高分辨率打印清晰。
|
||
|
|
const double kExportPixelRatio = 2.0;
|
||
|
|
|
||
|
|
/// 导出内容区域(标题/图例之外的内容区)。
|
||
|
|
const Rect kExportContentArea = Rect.fromLTRB(48, 128, 1872, 1016);
|
||
|
|
|
||
|
|
/// 导出内容变换:`scale` + `translate(tx, ty)`。
|
||
|
|
class ExportFit {
|
||
|
|
/// 构造内容变换。
|
||
|
|
const ExportFit(this.scale, this.tx, this.ty);
|
||
|
|
|
||
|
|
/// 缩放系数。
|
||
|
|
final double scale;
|
||
|
|
|
||
|
|
/// 水平平移。
|
||
|
|
final double tx;
|
||
|
|
|
||
|
|
/// 垂直平移。
|
||
|
|
final double ty;
|
||
|
|
|
||
|
|
/// SVG transform 属性值。
|
||
|
|
String get svgTransform =>
|
||
|
|
'translate(${tx.toStringAsFixed(1)} ${ty.toStringAsFixed(1)}) scale(${scale.toStringAsFixed(4)})';
|
||
|
|
}
|
||
|
|
|
||
|
|
/// 导出专用令牌:始终使用浅色、纯白背景(印刷 / 工艺卡导向),
|
||
|
|
/// 文字、语义色与屏幕浅色主题保持一致。
|
||
|
|
Tokens exportTokens(Tokens base) {
|
||
|
|
return Tokens(
|
||
|
|
brightness: Brightness.light,
|
||
|
|
bg: Colors.white,
|
||
|
|
canvas1: Colors.white,
|
||
|
|
canvas2: Colors.white,
|
||
|
|
chrome: base.chrome,
|
||
|
|
panel: Colors.white,
|
||
|
|
panel2: Colors.white,
|
||
|
|
dialog: Colors.white,
|
||
|
|
line: base.line,
|
||
|
|
line2: base.line2,
|
||
|
|
text: base.text,
|
||
|
|
text2: base.text2,
|
||
|
|
sub: base.sub,
|
||
|
|
dim: base.dim,
|
||
|
|
accent: base.accent,
|
||
|
|
accent2: base.accent2,
|
||
|
|
ok: base.ok,
|
||
|
|
warn: base.warn,
|
||
|
|
danger: base.danger,
|
||
|
|
fs: base.fs,
|
||
|
|
ss: base.ss,
|
||
|
|
crit: base.crit,
|
||
|
|
chip: Colors.white,
|
||
|
|
dial: Colors.white,
|
||
|
|
arcText: base.arcText,
|
||
|
|
onAccent: base.onAccent,
|
||
|
|
ringA: base.ringA,
|
||
|
|
ringB: base.ringB,
|
||
|
|
ringEdge: base.ringEdge,
|
||
|
|
ringLabel: base.ringLabel,
|
||
|
|
info: Colors.white,
|
||
|
|
track: base.track,
|
||
|
|
sel: base.sel,
|
||
|
|
grid: base.grid,
|
||
|
|
shadow: base.shadow,
|
||
|
|
shadowOp: 0.10,
|
||
|
|
selOutline: base.selOutline,
|
||
|
|
overlay: base.overlay,
|
||
|
|
tailOp: base.tailOp,
|
||
|
|
);
|
||
|
|
}
|