Skip to content

Commit b5c1609

Browse files
authored
Merge branch 'main' into MoveSelectionToAnotherPage
2 parents bc46c97 + 56784d6 commit b5c1609

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+93
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions

flatpak/com.adilhanney.saber.metainfo.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@
239239
</screenshots>
240240

241241
<releases>
242+
<release version="0.19.2" type="development" date="2024-01-16">
243+
<description>
244+
<p>Strokes that had jagged edges have now been smoothed out, particularly ones drawn with a mouse or trackpad.</p>
245+
</description>
246+
</release>
242247
<release version="0.19.1" type="development" date="2024-01-09">
243248
<description>
244249
<ul>

installers/desktop_inno_script.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "Saber"
5-
#define MyAppVersion "0.19.1"
5+
#define MyAppVersion "0.19.2"
66
#define MyAppPublisher "Adil Hanney"
77
#define MyAppURL "https://github.com/saber-notes/saber"
88
#define MyAppExeName "saber.exe"

lib/components/canvas/_circle_stroke.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class CircleStroke extends Stroke {
9393
.map((radians) => Offset(cos(radians), sin(radians)))
9494
.map((unitDir) => unitDir * radius + center)
9595
.toList();
96-
_path = Path()..addPolygon(_polygon, true);
96+
_path = Path()..addOval(Rect.fromCircle(center: center, radius: radius));
9797
_polygonNeedsUpdating = false;
9898
}
9999

lib/components/canvas/_rectangle_stroke.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class RectangleStroke extends Stroke {
8989

9090
void _updatePolygon() {
9191
_polygon = _getPolygon();
92-
_path = Path()..addPolygon(_polygon, true);
92+
_path = Path()..addRect(rect);
9393
_polygonNeedsUpdating = false;
9494
}
9595

lib/components/canvas/_stroke.dart

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Stroke {
4646

4747
void _updatePolygon() {
4848
_polygon = _getPolygon();
49-
_path = Path()..addPolygon(_polygon, true);
49+
_path = _getPath();
5050
_polygonNeedsUpdating = false;
5151
}
5252

@@ -174,6 +174,9 @@ class Stroke {
174174

175175
final minDistance = options.size * thresholdMultiplier;
176176

177+
// Remove points with null pressure because they were duplicates
178+
points.removeWhere((point) => point.pressure == null);
179+
177180
for (int i = 1; i < points.length - 1; i++) {
178181
final point = points[i];
179182
final prev = points[i - 1];
@@ -203,8 +206,6 @@ class Stroke {
203206
if (rememberSimulatedPressure) {
204207
// Ensure we don't simulate pressure again
205208
options.simulatePressure = false;
206-
// Remove points with null pressure because they were duplicates
207-
points.removeWhere((point) => point.pressure == null);
208209
// Remove points that are too close together
209210
optimisePoints();
210211
// Get polygon again with slightly different input
@@ -214,6 +215,29 @@ class Stroke {
214215
return polygon;
215216
}
216217

218+
/// Returns a [Path] that represents the stroke.
219+
///
220+
/// If the stroke is not complete,
221+
/// the path will just follow the polygon for performance.
222+
///
223+
/// If the stroke is complete,
224+
/// the path will be a smooth curve between the points.
225+
Path _getPath() {
226+
if (!options.isComplete) {
227+
return Path()..addPolygon(_polygon, true);
228+
}
229+
230+
final path = Path();
231+
path.moveTo(_polygon.first.dx, _polygon.first.dy);
232+
for (int i = 1; i < _polygon.length - 1; i++) {
233+
final p1 = _polygon[i];
234+
final p2 = _polygon[i + 1];
235+
final mid = (p1 + p2) / 2;
236+
path.quadraticBezierTo(p1.dx, p1.dy, mid.dx, mid.dy);
237+
}
238+
return path..close();
239+
}
240+
217241
String toSvgPath(Size pageSize) {
218242
String toSvgPoint(Offset point) {
219243
return '${point.dx} '

lib/data/tools/pen.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ class Pen extends Tool {
7373
currentStroke = Stroke(
7474
color: color,
7575
pressureEnabled: pressureEnabled,
76-
options: options.copyWith(),
76+
options: options.copyWith(
77+
isComplete: false,
78+
),
7779
pageIndex: pageIndex,
7880
penType: runtimeType.toString(),
7981
);

lib/data/version.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// Run `./scripts/apply_version.sh --help` for more information.
33

44
/// The current app version as an ordinal number.
5-
const int buildNumber = 19010;
5+
const int buildNumber = 19020;
66

77
/// The current app version as a string.
8-
const String buildName = '0.19.1';
8+
const String buildName = '0.19.2';
99

1010
/// The year in which the current version was released.
1111
const int buildYear = 2024;

metadata/ar/changelogs/19020.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
وقد تم الآن سلاسة الخنقات التي كانت تحمل حوافاً مزيفة، لا سيما تلك التي تم سحبها مع فأر أو صعقة.
2+
.

metadata/ar/changelogs/190203.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
metadata/ar/changelogs/19020.txt

0 commit comments

Comments
 (0)