-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add droplet,ellipse,heart,isogon,rose,star shape and tests.
- Loading branch information
Showing
33 changed files
with
948 additions
and
77 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Droplet, DropletShape } from 'zrender' | ||
import { BaseShape } from '../index' | ||
import { getCommonParams } from '../utils/getCommonParams' | ||
|
||
export type IDropletOptions = BaseShape<DropletShape> | ||
|
||
/** | ||
* 创建水滴 | ||
* @param options | ||
* @returns | ||
*/ | ||
function createDroplet(options?: IDropletOptions): Droplet { | ||
const { common, other } = getCommonParams(options) | ||
const { cx = 0, cy = 0, width = 0, height = 0, ...rest } = other | ||
const shape = new Droplet({ | ||
...common, | ||
shape: { | ||
cx, | ||
cy, | ||
width, | ||
height | ||
}, | ||
style: { | ||
fill: 'none', | ||
stroke: '#fff', | ||
...rest | ||
} | ||
}) | ||
return shape | ||
} | ||
|
||
export default createDroplet |
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,32 @@ | ||
import { Ellipse, EllipseShape } from 'zrender' | ||
import { BaseShape } from '../index' | ||
import { getCommonParams } from '../utils/getCommonParams' | ||
|
||
export type IDropletOptions = BaseShape<EllipseShape> | ||
|
||
/** | ||
* 创建椭圆 | ||
* @param options | ||
* @returns | ||
*/ | ||
function createEllipse(options?: IDropletOptions): Ellipse { | ||
const { common, other } = getCommonParams(options) | ||
const { cx = 0, cy = 0, rx = 0, ry = 0, ...rest } = other | ||
const shape = new Ellipse({ | ||
...common, | ||
shape: { | ||
cx, | ||
cy, | ||
rx, | ||
ry | ||
}, | ||
style: { | ||
fill: 'none', | ||
stroke: '#fff', | ||
...rest | ||
} | ||
}) | ||
return shape | ||
} | ||
|
||
export default createEllipse |
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,32 @@ | ||
import { Heart, HeartShape } from 'zrender' | ||
import { BaseShape } from '../index' | ||
import { getCommonParams } from '../utils/getCommonParams' | ||
|
||
export type IHeartOptions = BaseShape<HeartShape> | ||
|
||
/** | ||
* 创建心形 | ||
* @param options | ||
* @returns | ||
*/ | ||
function createHeart(options?: IHeartOptions): Heart { | ||
const { common, other } = getCommonParams(options) | ||
const { cx = 0, cy = 0, width = 0, height = 0, ...rest } = other | ||
const shape = new Heart({ | ||
...common, | ||
shape: { | ||
cx, | ||
cy, | ||
width, | ||
height | ||
}, | ||
style: { | ||
fill: 'none', | ||
stroke: '#fff', | ||
...rest | ||
} | ||
}) | ||
return shape | ||
} | ||
|
||
export default createHeart |
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,32 @@ | ||
import { Isogon, IsogonShape } from 'zrender' | ||
import { BaseShape } from '../index' | ||
import { getCommonParams } from '../utils/getCommonParams' | ||
|
||
export type IIsogonOptions = BaseShape<IsogonShape> | ||
|
||
/** | ||
* 创建正多边形 | ||
* @param options | ||
* @returns | ||
*/ | ||
function createIsogon(options?: IIsogonOptions): Isogon { | ||
const { common, other } = getCommonParams(options) | ||
const { x = 0, y = 0, r = 0, n = 0, ...rest } = other | ||
const shape = new Isogon({ | ||
...common, | ||
shape: { | ||
x, | ||
y, | ||
r, | ||
n | ||
}, | ||
style: { | ||
fill: 'none', | ||
stroke: '#fff', | ||
...rest | ||
} | ||
}) | ||
return shape | ||
} | ||
|
||
export default createIsogon |
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,33 @@ | ||
import { Rose, RoseShape } from 'zrender' | ||
import { BaseShape } from '../index' | ||
import { getCommonParams } from '../utils/getCommonParams' | ||
|
||
export type IRoseOptions = BaseShape<RoseShape> | ||
|
||
/** | ||
* 玫瑰线 | ||
* @param options | ||
* @returns | ||
*/ | ||
function createRose(options?: IRoseOptions): Rose { | ||
const { common, other } = getCommonParams(options) | ||
const { cx = 0, cy = 0, r = [], n = 1, k = 0, ...rest } = other | ||
const shape = new Rose({ | ||
...common, | ||
shape: { | ||
cx, | ||
cy, | ||
n, | ||
r, | ||
k | ||
}, | ||
style: { | ||
fill: 'none', | ||
stroke: '#fff', | ||
...rest | ||
} | ||
}) | ||
return shape | ||
} | ||
|
||
export default createRose |
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,33 @@ | ||
import { Star, StarShape } from 'zrender' | ||
import { BaseShape } from '../index' | ||
import { getCommonParams } from '../utils/getCommonParams' | ||
|
||
export type IStarOptions = BaseShape<StarShape> | ||
|
||
/** | ||
* 创建星形 | ||
* @param options | ||
* @returns | ||
*/ | ||
function createStar(options?: IStarOptions): Star { | ||
const { common, other } = getCommonParams(options) | ||
const { cx = 0, cy = 0, r = 0, n = 3, r0 = 0, ...rest } = other | ||
const shape = new Star({ | ||
...common, | ||
shape: { | ||
cx, | ||
cy, | ||
n, | ||
r, | ||
r0 | ||
}, | ||
style: { | ||
fill: 'none', | ||
stroke: '#fff', | ||
...rest | ||
} | ||
}) | ||
return shape | ||
} | ||
|
||
export default createStar |
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
Oops, something went wrong.