Skip to content

Commit

Permalink
feat: add one point support for line mark. (#306)
Browse files Browse the repository at this point in the history
Co-authored-by: dan12411 <[email protected]>
  • Loading branch information
dan12411 and dan12411 authored Jul 26, 2024
1 parent 44fbd01 commit 0cd16d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/src/graffiti/element/polyline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PolylineElement extends PrimitiveElement {
double? rotation,
Offset? rotationAxis,
String? tag,
}) : assert(points.length >= 2),
}) : assert(points.isNotEmpty),
super(
style: style,
rotation: rotation,
Expand Down
10 changes: 7 additions & 3 deletions lib/src/shape/line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,15 @@ class BasicLineShape extends LineShape {
final primitives = <MarkElement>[];

final represent = group.first;
final style = getPaintStyle(
represent, true, represent.size ?? defaultSize, coord.region, dash);
final strokeWidth = represent.size ?? defaultSize;
final style =
getPaintStyle(represent, true, strokeWidth, coord.region, dash);

for (var contour in contours) {
if (smooth) {
if (contour.length == 1) {
primitives.add(CircleElement(
center: contour[0], radius: strokeWidth / 2, style: style));
} else if (smooth) {
primitives.add(SplineElement(
start: contour.first,
cubics: getCubicControls(contour, false, true),
Expand Down

0 comments on commit 0cd16d1

Please sign in to comment.