-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
120 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default (layout) => { | ||
const { left, top, width } = layout; | ||
const r = width / 2; | ||
return { | ||
x: left + r, | ||
y: top + r, | ||
r, | ||
} | ||
} |
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,18 @@ | ||
import rect from './rect'; | ||
import line from './line'; | ||
import text from './text'; | ||
import circle from './circle'; | ||
import marker from './marker'; | ||
|
||
const map = { | ||
rect, | ||
line, | ||
text, | ||
circle, | ||
marker, | ||
} | ||
|
||
export default (type: string, layout) => { | ||
const fn = map[type] || rect; | ||
return fn(layout); | ||
} |
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
// const { width, height, left, top, right, bo } = layout; | ||
export default (layout) => { | ||
const { left, top, width, height } = layout; | ||
const halfHeight = height / 2; | ||
return { | ||
x1: left, | ||
y1: top + halfHeight, | ||
x2: left + width, | ||
y2: top + halfHeight, | ||
lineWidth: height, | ||
} | ||
} | ||
|
||
|
||
// element = container.addShape(type, { | ||
// ...props, | ||
// attrs: { | ||
// x1: left, | ||
// y1: top, | ||
// x2: left + width, | ||
// y2: top + height, | ||
// ...attrs, | ||
// }, | ||
// }); |
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,9 @@ | ||
export default (layout) => { | ||
const { left, top, width } = layout; | ||
const r = width / 2; | ||
return { | ||
x: left + r, | ||
y: top + r, | ||
radius: r, | ||
} | ||
} |
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,9 @@ | ||
export default (layout) => { | ||
const { left, top, width, height } = layout; | ||
return { | ||
x: left, | ||
y: top, | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default (layout) => { | ||
const { width, height, left, top } = layout; | ||
return { | ||
x: left, | ||
y: top + (height / 2), | ||
// 通过middle + top 才能比较好的实现文本对齐 | ||
textBaseline: 'middle', | ||
} | ||
} |
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