diff --git a/lib/components/canvas/_stroke.dart b/lib/components/canvas/_stroke.dart index b44d3866f..0b88095c3 100644 --- a/lib/components/canvas/_stroke.dart +++ b/lib/components/canvas/_stroke.dart @@ -71,6 +71,8 @@ class Stroke { }..addAll(strokeProperties.toJson()); addPoint(EditorCoreInfo context, Offset offset, [ double? pressure ]) { + if (!strokeProperties.pressureEnabled) pressure = null; + double x = max(min(offset.dx, context.width), 0); double y = max(min(offset.dy, context.height), 0); Point point = Point(x, y, pressure ?? 0.5); @@ -106,7 +108,7 @@ class Stroke { taperEnd: strokeProperties.taperEnd, capStart: strokeProperties.capStart, capEnd: strokeProperties.capEnd, - simulatePressure: strokeProperties.simulatePressure, + simulatePressure: strokeProperties.simulatePressure && strokeProperties.pressureEnabled, ) .map((Point point) => Offset(point.x, point.y)) .toList(growable: false); diff --git a/lib/components/canvas/tools/stroke_properties.dart b/lib/components/canvas/tools/stroke_properties.dart index 132a00b24..325920c34 100644 --- a/lib/components/canvas/tools/stroke_properties.dart +++ b/lib/components/canvas/tools/stroke_properties.dart @@ -23,7 +23,7 @@ class StrokeProperties { double taperEnd = defaultTaperEnd; bool capStart = defaultCapStart; bool capEnd = defaultCapEnd; - bool pressureEnabled = defaultPressureEnabled; // todo: don't use pressure sensitivity if false + bool pressureEnabled = defaultPressureEnabled; bool simulatePressure = defaultSimulatePressure; StrokeProperties({ @@ -49,6 +49,7 @@ class StrokeProperties { taperEnd = json['te'] ?? defaultTaperEnd; capStart = json['cs'] ?? defaultCapStart; capEnd = json['ce'] ?? defaultCapEnd; + pressureEnabled = json['pe'] ?? defaultPressureEnabled; simulatePressure = json['sp'] ?? defaultSimulatePressure; } Map toJson() => { @@ -61,6 +62,7 @@ class StrokeProperties { if (taperEnd != defaultTaperEnd) 'te': taperEnd, if (capStart != defaultCapStart) 'cs': capStart, if (capEnd != defaultCapEnd) 'ce': capEnd, + if (pressureEnabled != defaultPressureEnabled) 'pe': pressureEnabled, if (simulatePressure != defaultSimulatePressure) 'sp': simulatePressure, };