|
@@ -338,7 +338,65 @@ export default () => {
|
|
|
offset,
|
|
offset,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const parseLineElement = (el: Shape, ratio: number) => {
|
|
|
|
|
+ let start: [number, number] = [0, 0]
|
|
|
|
|
+ let end: [number, number] = [0, 0]
|
|
|
|
|
+
|
|
|
|
|
+ if (!el.isFlipV && !el.isFlipH) { // 右下
|
|
|
|
|
+ start = [0, 0]
|
|
|
|
|
+ end = [el.width, el.height]
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (el.isFlipV && el.isFlipH) { // 左上
|
|
|
|
|
+ start = [el.width, el.height]
|
|
|
|
|
+ end = [0, 0]
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (el.isFlipV && !el.isFlipH) { // 右上
|
|
|
|
|
+ start = [0, el.height]
|
|
|
|
|
+ end = [el.width, 0]
|
|
|
|
|
+ }
|
|
|
|
|
+ else { // 左下
|
|
|
|
|
+ start = [el.width, 0]
|
|
|
|
|
+ end = [0, el.height]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const data: PPTLineElement = {
|
|
|
|
|
+ type: 'line',
|
|
|
|
|
+ id: nanoid(10),
|
|
|
|
|
+ width: +((el.borderWidth || 1) * ratio).toFixed(2),
|
|
|
|
|
+ left: el.left,
|
|
|
|
|
+ top: el.top,
|
|
|
|
|
+ start,
|
|
|
|
|
+ end,
|
|
|
|
|
+ style: el.borderType,
|
|
|
|
|
+ color: el.borderColor,
|
|
|
|
|
+ points: ['', /straightConnector/.test(el.shapType) ? 'arrow' : '']
|
|
|
|
|
+ }
|
|
|
|
|
+ if (el.rotate) {
|
|
|
|
|
+ const { start, end, offset } = rotateLine(data, el.rotate)
|
|
|
|
|
+
|
|
|
|
|
+ data.start = start
|
|
|
|
|
+ data.end = end
|
|
|
|
|
+ data.left = data.left + offset[0]
|
|
|
|
|
+ data.top = data.top + offset[1]
|
|
|
|
|
+ }
|
|
|
|
|
+ if (/bentConnector/.test(el.shapType)) {
|
|
|
|
|
+ data.broken2 = [
|
|
|
|
|
+ Math.abs(data.start[0] - data.end[0]) / 2,
|
|
|
|
|
+ Math.abs(data.start[1] - data.end[1]) / 2,
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ if (/curvedConnector/.test(el.shapType)) {
|
|
|
|
|
+ const cubic: [number, number] = [
|
|
|
|
|
+ Math.abs(data.start[0] - data.end[0]) / 2,
|
|
|
|
|
+ Math.abs(data.start[1] - data.end[1]) / 2,
|
|
|
|
|
+ ]
|
|
|
|
|
+ data.cubic = [cubic, cubic]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return data
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const flipGroupElements = (elements: BaseElement[], axis: 'x' | 'y') => {
|
|
const flipGroupElements = (elements: BaseElement[], axis: 'x' | 'y') => {
|
|
|
const minX = Math.min(...elements.map(el => el.left))
|
|
const minX = Math.min(...elements.map(el => el.left))
|
|
|
const maxX = Math.max(...elements.map(el => el.left + el.width))
|
|
const maxX = Math.max(...elements.map(el => el.left + el.width))
|