Documentation & licensing: - Add the EUPL-1.2 licence (LICENSE.md) and set the project licence; refresh the README (name origin wink, updated feature list, documentation index). - Add CONTRIBUTING, SECURITY, CODE_OF_CONDUCT, CHANGELOG, AUTHORS, and THIRD_PARTY_NOTICES, plus docs/ (ARCHITECTURE, BUILD, USER_GUIDE, SHORTCUTS, LICENSE_COMPLIANCE) and .github/ (CI workflow, issue/PR templates). - Bring docs/FILE_FORMAT.md in line with current behaviour (code & chart slides, per-slide TLP comment, annotation .ink.json sidecar, chart data/ CSVs). Open-source compliance: - Add tool/check_licenses.dart and a `make licenses` target (wired into check-full and CI) that verifies every resolved dependency uses a recognised open-source licence. A scan of all 151 packages and bundled assets found only OSI-approved licences. Charts (Fase 1.1): - Replace the chart CSV textarea with an in-app editable data grid (editable series/labels/values, add/remove row & column, read-only when linked). - Centralize the linked-CSV directory name (`data/`) in a shared constant. Also normalize formatting repo-wide with `dart format` and fix one curly-braces lint, so `make check` and CI are green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
70 lines
2.2 KiB
Dart
70 lines
2.2 KiB
Dart
import 'dart:ui';
|
|
|
|
/// Annotation tools available while presenting. Drawings live in a layer that
|
|
/// is fully separate from the Marp content — they are never written to the
|
|
/// markdown.
|
|
enum InkTool { laser, pen, highlighter, eraser }
|
|
|
|
/// A single freehand stroke on the annotation layer.
|
|
///
|
|
/// Coordinates are normalized (0..1) within the 16:9 slide rectangle and the
|
|
/// width is a fraction of the slide width, so a stroke renders identically on
|
|
/// the laptop preview and the beamer regardless of resolution or letterboxing.
|
|
class InkStroke {
|
|
final InkTool tool;
|
|
final int color; // ARGB
|
|
final double width; // fraction of the slide width
|
|
final List<Offset> points; // normalized 0..1
|
|
|
|
const InkStroke({
|
|
required this.tool,
|
|
required this.color,
|
|
required this.width,
|
|
required this.points,
|
|
});
|
|
|
|
InkStroke copyWith({List<Offset>? points}) => InkStroke(
|
|
tool: tool,
|
|
color: color,
|
|
width: width,
|
|
points: points ?? this.points,
|
|
);
|
|
|
|
/// Compact JSON: points are flattened to [x0, y0, x1, y1, …].
|
|
Map<String, dynamic> toJson() => {
|
|
'tool': tool.name,
|
|
'color': color,
|
|
'width': width,
|
|
'points': [
|
|
for (final p in points) ...[_round(p.dx), _round(p.dy)],
|
|
],
|
|
};
|
|
|
|
static double _round(double v) => (v * 10000).roundToDouble() / 10000;
|
|
|
|
factory InkStroke.fromJson(Map<String, dynamic> json) {
|
|
final raw = (json['points'] as List?)?.cast<num>() ?? const [];
|
|
final pts = <Offset>[];
|
|
for (var i = 0; i + 1 < raw.length; i += 2) {
|
|
pts.add(Offset(raw[i].toDouble(), raw[i + 1].toDouble()));
|
|
}
|
|
return InkStroke(
|
|
tool: InkTool.values.firstWhere(
|
|
(t) => t.name == json['tool'],
|
|
orElse: () => InkTool.pen,
|
|
),
|
|
color: (json['color'] as num?)?.toInt() ?? 0xFFEF4444,
|
|
width: (json['width'] as num?)?.toDouble() ?? 0.004,
|
|
points: pts,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Encode/decode a per-slide map of strokes keyed by slide id.
|
|
List<Map<String, dynamic>> encodeStrokes(List<InkStroke> strokes) => [
|
|
for (final s in strokes) s.toJson(),
|
|
];
|
|
|
|
List<InkStroke> decodeStrokes(List<dynamic> raw) => [
|
|
for (final e in raw) InkStroke.fromJson(Map<String, dynamic>.from(e as Map)),
|
|
];
|