fix(export): single-source freehand recipe screen+export (P0 step 7, R7)
pdf_service._buildFreehandPdfPath hardcoded its OWN StrokeOptions (thinning:0.7, streamline:0.5) instead of the shared geometry — the R7 hairline-export divergence. The prior pen-feel commit (streamline 0.5→0.32 on screen) widened the gap: export still rendered at 0.5. Extract the ONE perfect_freehand recipe into stroke_geometry.freehandOutlinePoints (owns thinning/smoothing/streamline/simulatePressure). buildStrokeOutline (screen) and pdf_service (export, via InkStroke→pfPoints) now both call it, so the StrokeOptions live in exactly one place and screen↔export can't drift again. Export now matches screen: thinning 0.85 (kDefaultPenThinning), streamline 0.32. test/export_geometry_test.dart pins it: buildStrokeOutline traces exactly the shared outline; default thinning == kDefaultPenThinning; thinning is wired; empty input is safe. flutter analyze lib/editor clean; 78/78 tests pass (+4). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:path_provider/path_provider.dart';
|
||||
import 'package:perfect_freehand/perfect_freehand.dart' as pf;
|
||||
import 'package:syncfusion_flutter_pdf/pdf.dart';
|
||||
|
||||
import '../editor/engine/stroke_geometry.dart' show freehandOutlinePoints;
|
||||
import '../models/ink_stroke.dart';
|
||||
import '../models/pen_tool.dart';
|
||||
|
||||
@@ -304,19 +305,15 @@ class PdfService {
|
||||
)
|
||||
.toList();
|
||||
|
||||
final outline = pf.getStroke(
|
||||
pfPoints,
|
||||
options: pf.StrokeOptions(
|
||||
size: pixelWidth,
|
||||
// Highlighter keeps constant width; pen/marker taper via thinning=0.7.
|
||||
thinning: isHighlighter ? 0.0 : 0.7,
|
||||
smoothing: 0.5,
|
||||
streamline: 0.5,
|
||||
// Real stylus pressure -> don't simulate; no pressure -> let freehand
|
||||
// fake it based on velocity. Highlighter never simulates.
|
||||
simulatePressure: !hasRealPressure && !isHighlighter,
|
||||
isComplete: true,
|
||||
),
|
||||
// ONE shared recipe with the on-screen painter (R7): export can no longer
|
||||
// drift from screen. Previously this hardcoded thinning:0.7/streamline:0.5,
|
||||
// which diverged from the screen's 0.85/0.32 → hairline export mismatch.
|
||||
final outline = freehandOutlinePoints(
|
||||
pfPoints: pfPoints,
|
||||
size: pixelWidth,
|
||||
isHighlighter: isHighlighter,
|
||||
hasRealPressure: hasRealPressure,
|
||||
isComplete: true,
|
||||
);
|
||||
|
||||
if (outline.isEmpty) return null;
|
||||
|
||||
Reference in New Issue
Block a user