Files
BadNote/lib/editor/canvas/pen_stroke.dart
Akiba So 3febbd1431
All checks were successful
CI / Windows build (push) Successful in 8m22s
feat(editor): pen canvas + Material You UI
Clean-room reimplementation of Saber's input model: we own the gesture
pipeline so pen draws with real pressure (perfect_freehand), two-finger
pinch zooms/pans, and palm is rejected (stylus-priority, 2nd-pointer
cancels stroke). pdfrx renders one page at a time (PdfPageView, no
gestures) under a shared transform; page-based nav. Material You theme
via dynamic_color (system accent + seed fallback) and a floating tonal
tool palette + page pill. Old pdfrx-overlay spike no longer wired.
2026-06-21 22:04:49 +08:00

48 lines
1.3 KiB
Dart

// lib/editor/canvas/pen_stroke.dart
//
// Pen-first canvas stroke model. Points are stored in NORMALIZED page
// coordinates ([0,1] x [0,1] relative to the page rectangle) so strokes stay
// pinned to the page regardless of zoom/pan or the on-screen page size.
import 'package:flutter/foundation.dart';
/// A single captured sample of a stroke.
///
/// [x]/[y] are normalized to the page rectangle ([0,1]).
/// [pressure] is the normalized stylus pressure ([0,1]) or null when the
/// device reported no usable pressure (perfect_freehand then simulates it).
@immutable
class PenPoint {
const PenPoint(this.x, this.y, this.pressure);
final double x;
final double y;
final double? pressure;
}
/// Which kind of mark a stroke is.
enum PenStrokeKind { pen, highlighter }
/// A committed stroke for a single page, in normalized page coordinates.
@immutable
class PenStroke {
const PenStroke({
required this.points,
required this.color,
required this.width,
required this.kind,
});
/// Normalized points (see [PenPoint]).
final List<PenPoint> points;
/// ARGB color value.
final int color;
/// Stroke width expressed as a fraction of the page width, so it scales with
/// the page when zoomed. Multiply by the on-screen page width to get pixels.
final double width;
final PenStrokeKind kind;
}