Skip to content

Commit

Permalink
feat(draw): support vector pen set fill color #WIK-15919
Browse files Browse the repository at this point in the history
  • Loading branch information
MissLixf committed Jul 4, 2024
2 parents 1cca57d + 7d1e713 commit 51e58a6
Show file tree
Hide file tree
Showing 29 changed files with 337 additions and 198 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-candles-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@plait/draw': patch
---

add isDrawElementClosed function
5 changes: 5 additions & 0 deletions .changeset/modern-clocks-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@plait/draw': patch
---

throw new Error when get cell points
5 changes: 5 additions & 0 deletions .changeset/rotten-insects-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@plait/draw': patch
---

fix link swimlane error by autocomplete
5 changes: 5 additions & 0 deletions .changeset/yellow-chairs-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@plait/draw': patch
---

adjust line dash value for dotted
99 changes: 49 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"graphology": "^0.25.4",
"graphology-layout": "^0.6.1",
"graphology-layout-forceatlas2": "^0.10.1",
"graphology-types": "^0.24.7",
"is-hotkey": "^0.2.0",
"points-on-curve": "^1.0.0",
"roughjs": "^4.5.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/utils/drawing/rectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ export function drawRoundRectangle(
const point7 = [x1, y2 - radius];
const point8 = [x1, y1 + radius];

return rs.path(
const rectangleG = rs.path(
`M${point2[0]} ${point2[1]} A ${radius} ${radius}, 0, 0, 1, ${point3[0]} ${point3[1]} L ${point4[0]} ${point4[1]} A ${radius} ${radius}, 0, 0, 1, ${point5[0]} ${point5[1]} L ${point6[0]} ${point6[1]} A ${radius} ${radius}, 0, 0, 1, ${point7[0]} ${point7[1]} L ${point8[0]} ${point8[1]} A ${radius} ${radius}, 0, 0, 1, ${point1[0]} ${point1[1]} Z`,
options
);
setStrokeLinecap(rectangleG, 'round');
return rectangleG;
}

export const drawRectangle = (board: PlaitBoard, rectangle: RectangleClient, options: Options) => {
Expand Down
8 changes: 8 additions & 0 deletions packages/draw/src/constants/geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,11 @@ export const GEOMETRY_WITHOUT_TEXT = [
] as GeometryShapes[];

export const GEOMETRY_WITH_MULTIPLE_TEXT = [UMLSymbols.package, UMLSymbols.combinedFragment];

export const GEOMETRY_NOT_CLOSED = [
FlowchartSymbols.noteCurlyLeft,
FlowchartSymbols.noteCurlyRight,
FlowchartSymbols.noteSquare,
UMLSymbols.requiredInterface,
UMLSymbols.deletion
] as GeometryShapes[];
7 changes: 5 additions & 2 deletions packages/draw/src/engines/basic-shapes/ellipse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
getEllipseTangentSlope,
getVectorFromPointAndSlope,
isPointInEllipse,
getNearestPointBetweenPointAndEllipse
getNearestPointBetweenPointAndEllipse,
setStrokeLinecap
} from '@plait/core';
import { PlaitGeometry, ShapeEngine } from '../../interfaces';
import { Options } from 'roughjs/bin/core';
Expand All @@ -22,7 +23,9 @@ export function createEllipseEngine(createOptions?: CreateEllipseOptions): Shape
draw(board: PlaitBoard, rectangle: RectangleClient, options: Options) {
const centerPoint = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2];
const rs = PlaitBoard.getRoughSVG(board);
return rs.ellipse(centerPoint[0], centerPoint[1], rectangle.width, rectangle.height, { ...options, fillStyle: 'solid' });
const shape = rs.ellipse(centerPoint[0], centerPoint[1], rectangle.width, rectangle.height, { ...options, fillStyle: 'solid' });
setStrokeLinecap(shape, 'round');
return shape;
},
isInsidePoint(rectangle: RectangleClient, point: Point) {
const centerPoint: Point = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2];
Expand Down
Loading

0 comments on commit 51e58a6

Please sign in to comment.