-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #891 from VisActor/fix/rect-split
Fix/rect split
- Loading branch information
Showing
6 changed files
with
140 additions
and
16 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common/changes/@visactor/vrender-core/fix-rect-split_2024-01-12-02-59.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"comment": "fix: fix `splitRect` when rect has `x1` or `y1`\n\n", | ||
"type": "none", | ||
"packageName": "@visactor/vrender-core" | ||
} | ||
], | ||
"packageName": "@visactor/vrender-core", | ||
"email": "[email protected]" | ||
} |
11 changes: 11 additions & 0 deletions
11
common/changes/@visactor/vrender/fix-rect-split_2024-01-12-02-59.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"comment": "fix: fix `splitRect` when rect has `x1` or `y1`\n\n", | ||
"type": "none", | ||
"packageName": "@visactor/vrender" | ||
} | ||
], | ||
"packageName": "@visactor/vrender", | ||
"email": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { isNil } from '@visactor/vutils'; | ||
import type { IRectGraphicAttribute } from '../interface/graphic/rect'; | ||
|
||
export const normalizeRectAttributes = (attribute: IRectGraphicAttribute) => { | ||
if (!attribute) { | ||
return { x: 0, y: 0, width: 0, height: 0 }; | ||
} | ||
|
||
let width = isNil(attribute.width) ? attribute.x1 - attribute.x : attribute.width; | ||
let height = isNil(attribute.height) ? attribute.y1 - attribute.y : attribute.height; | ||
let x = 0; | ||
let y = 0; | ||
|
||
if (width < 0) { | ||
x = width; | ||
width = -width; | ||
} else if (Number.isNaN(width)) { | ||
width = 0; | ||
} | ||
|
||
if (height < 0) { | ||
y = height; | ||
height = -height; | ||
} else if (Number.isNaN(height)) { | ||
height = 0; | ||
} | ||
|
||
return { x, y, width, height }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters