Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/conic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Conic {

// Split conic into quads, writes quad coordinates into [_pointList] and
// returns number of quads.
assert(subdivideCount > 0);
assert(subdivideCount >= 0 && subdivideCount <= _maxSubdivisionCount);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't subdivideCount <= _maxSubdivisionCount guaranteed by the implementation of _computeSubdivisionCount?

The documentation of _computeSubdivisionCount says: The number of subdivisions never exceed _maxSubdivisionCount

Should the second half of this assert be moved to the _countSubdivisionCount method, so the postcondition in the documentation is "guaranteed"?

assert(pow2 <= _maxSubdivisionCount);
return pow2;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added check here to make sure if implementation breaks, this will throw.

int quadCount = 1 << subdivideCount;
bool skipSubdivide = false;
pointList.add(ui.Offset(p0x, p0y));
Expand Down
8 changes: 7 additions & 1 deletion lib/web_ui/test/path_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// found in the LICENSE file.

// @dart = 2.6
import 'package:test/test.dart';
import 'dart:js_util' as js_util;
import 'dart:html' as html;
import 'package:test/test.dart';
import 'package:ui/ui.dart' hide window;
import 'package:ui/src/engine.dart';

Expand Down Expand Up @@ -309,4 +309,10 @@ void main() {
expect(path2.contains(Offset(100, 100)), isFalse);
expect(path2.contains(Offset(50, 100)), isFalse);
});

test('Should convert conic to quad when approximation error is small', () {
Conic conic = Conic(120.0, 20.0, 160.99470420829266, 20.0,
190.19301120261332, 34.38770865870253, 0.9252691032413082);
expect(conic.toQuads().length, 3);
});
}