fix:修改 topology 源码 删除创建的节点以及给节点创建的对应的事件

This commit is contained in:
zhangyu
2022-07-14 09:55:10 +08:00
parent 739fa3e82f
commit 73b71d578f
186 changed files with 5955 additions and 6025 deletions

File diff suppressed because one or more lines are too long

View File

@@ -60,10 +60,10 @@ export default {
if (res2.length == 0) {
this.topologyLoading = false
}
// res2.forEach(item => {
// temp.push(item)
// })
temp.push(res2[2])
res2.forEach(item => {
temp.push(item)
})
// temp.push(res2[2])
this.allProject = JSON.parse(JSON.stringify(temp))
temp = null
axiosAll = null
@@ -101,6 +101,9 @@ export default {
},
mounted () {
this.queryAllProjectData()
},
beforeDestroy () {
this.allProject = []
}
}
</script>

View File

@@ -28,7 +28,7 @@ import { formatScientificNotation, getMetricTypeValue } from '@/components/commo
import chartDataFormat from '@/components/chart/chartDataFormat'
import { initColor } from '@/components/chart/chart/tools'
import lodash from 'lodash'
import bus from "@/libs/bus";
import bus from '@/libs/bus'
export default {
name: 'chart-bar',

View File

@@ -293,7 +293,6 @@ export default {
}
},
mounted () {
this.chartId = `${this.chartInfo.id}${this.isFullscreen ? '-fullscreen' : ''}`
},
beforeDestroy () {

View File

@@ -496,7 +496,7 @@ export default {
xhr.responseType = ''
// 创建一个 post 请求,采用异步
xhr.open('get', 'http://192.168.44.100/' + nowUrl, true)
xhr.setRequestHeader('Authorization', localStorage.getItem('nz-token'));
xhr.setRequestHeader('Authorization', localStorage.getItem('nz-token'))
// 注册相关事件回调处理函数
xhr.onload = function (e) {
if (this.status == 200 || this.status == 304) {
@@ -504,7 +504,7 @@ export default {
resolve(JSON.parse(this.responseText))
}
}
xhr.onerror = function(e) { console.log(e) };
xhr.onerror = function (e) { console.log(e) }
// 发送数据
xhr.send()
})

View File

@@ -1,6 +1,6 @@
export * from './src/final';
export * from './src/fork';
export * from './src/swimlaneH';
export * from './src/swimlaneV';
export * from './src/register';
//# sourceMappingURL=index.js.map
export * from './src/final'
export * from './src/fork'
export * from './src/swimlaneH'
export * from './src/swimlaneV'
export * from './src/register'
// # sourceMappingURL=index.js.map

View File

@@ -1,10 +1,10 @@
export function activityFinal(ctx, node) {
ctx.beginPath();
ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 2, node.rect.height / 2, 0, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.fillStyle = ctx.strokeStyle;
ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 4, node.rect.height / 4, 0, 0, Math.PI * 2);
ctx.fill();
export function activityFinal (ctx, node) {
ctx.beginPath()
ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 2, node.rect.height / 2, 0, 0, Math.PI * 2)
ctx.stroke()
ctx.beginPath()
ctx.fillStyle = ctx.strokeStyle
ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 4, node.rect.height / 4, 0, 0, Math.PI * 2)
ctx.fill()
}
//# sourceMappingURL=final.js.map
// # sourceMappingURL=final.js.map

View File

@@ -1,11 +1,11 @@
import { Rect } from '@topology/core';
export function activityFinalIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
import { Rect } from '@topology/core'
export function activityFinalIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function activityFinalTextRect(node) {
var w = (node.rect.width * 5) / 7;
var h = (node.rect.height * 5) / 7;
node.textRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h);
node.fullTextRect = node.textRect;
export function activityFinalTextRect (node) {
const w = (node.rect.width * 5) / 7
const h = (node.rect.height * 5) / 7
node.textRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h)
node.fullTextRect = node.textRect
}
//# sourceMappingURL=final.rect.js.map
// # sourceMappingURL=final.rect.js.map

View File

@@ -1,3 +1,3 @@
export * from './final';
export * from './final.rect';
//# sourceMappingURL=index.js.map
export * from './final'
export * from './final.rect'
// # sourceMappingURL=index.js.map

View File

@@ -1,28 +1,28 @@
import { Point, Direction } from '@topology/core';
export function forkHAnchors(node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left));
node.anchors.push(new Point(node.rect.ex, node.rect.y + node.rect.height / 2, Direction.Right));
var dis = 5;
for (var i = dis; node.rect.x + i < node.rect.ex; i = i + dis) {
var pt1 = new Point(node.rect.x + i, node.rect.y, Direction.Up);
var pt2 = new Point(node.rect.x + i, node.rect.ey, Direction.Bottom);
pt1.hidden = true;
pt2.hidden = true;
node.anchors.push(pt1);
node.anchors.push(pt2);
}
import { Point, Direction } from '@topology/core'
export function forkHAnchors (node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left))
node.anchors.push(new Point(node.rect.ex, node.rect.y + node.rect.height / 2, Direction.Right))
const dis = 5
for (let i = dis; node.rect.x + i < node.rect.ex; i = i + dis) {
const pt1 = new Point(node.rect.x + i, node.rect.y, Direction.Up)
const pt2 = new Point(node.rect.x + i, node.rect.ey, Direction.Bottom)
pt1.hidden = true
pt2.hidden = true
node.anchors.push(pt1)
node.anchors.push(pt2)
}
}
export function forkVAnchors(node) {
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.ey, Direction.Bottom));
var dis = 5;
for (var i = dis; node.rect.y + i < node.rect.ey; i = i + dis) {
var pt1 = new Point(node.rect.x, node.rect.y + i, Direction.Left);
var pt2 = new Point(node.rect.ex, node.rect.y + i, Direction.Right);
pt1.hidden = true;
pt2.hidden = true;
node.anchors.push(pt1);
node.anchors.push(pt2);
}
export function forkVAnchors (node) {
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up))
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.ey, Direction.Bottom))
const dis = 5
for (let i = dis; node.rect.y + i < node.rect.ey; i = i + dis) {
const pt1 = new Point(node.rect.x, node.rect.y + i, Direction.Left)
const pt2 = new Point(node.rect.ex, node.rect.y + i, Direction.Right)
pt1.hidden = true
pt2.hidden = true
node.anchors.push(pt1)
node.anchors.push(pt2)
}
}
//# sourceMappingURL=fork.anchor.js.map
// # sourceMappingURL=fork.anchor.js.map

View File

@@ -1,25 +1,25 @@
export function fork(ctx, node) {
var wr = node.borderRadius;
var hr = node.borderRadius;
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius;
hr = node.rect.height * node.borderRadius;
}
var r = wr < hr ? wr : hr;
if (node.rect.width < 2 * r) {
r = node.rect.width / 2;
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2;
}
ctx.beginPath();
ctx.moveTo(node.rect.x + r, node.rect.y);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r);
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r);
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function fork (ctx, node) {
let wr = node.borderRadius
let hr = node.borderRadius
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius
hr = node.rect.height * node.borderRadius
}
let r = wr < hr ? wr : hr
if (node.rect.width < 2 * r) {
r = node.rect.width / 2
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2
}
ctx.beginPath()
ctx.moveTo(node.rect.x + r, node.rect.y)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r)
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r)
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=fork.js.map
// # sourceMappingURL=fork.js.map

View File

@@ -1,9 +1,9 @@
import { Rect } from '@topology/core';
export function forkIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
import { Rect } from '@topology/core'
export function forkIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function forkTextRect(node) {
node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, node.rect.height);
node.fullTextRect = node.textRect;
export function forkTextRect (node) {
node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, node.rect.height)
node.fullTextRect = node.textRect
}
//# sourceMappingURL=fork.rect.js.map
// # sourceMappingURL=fork.rect.js.map

View File

@@ -1,4 +1,4 @@
export * from './fork';
export * from './fork.rect';
export * from './fork.anchor';
//# sourceMappingURL=index.js.map
export * from './fork'
export * from './fork.rect'
export * from './fork.anchor'
// # sourceMappingURL=index.js.map

View File

@@ -1,13 +1,13 @@
import { registerNode } from '@topology/core';
import { activityFinal, activityFinalIconRect, activityFinalTextRect } from './final';
import { fork, forkHAnchors, forkVAnchors, forkIconRect, forkTextRect } from './fork';
import { swimlaneH, swimlaneHIconRect, swimlaneHTextRect } from './swimlaneH';
import { swimlaneV, swimlaneVIconRect, swimlaneVTextRect } from './swimlaneV';
export function register() {
registerNode('activityFinal', activityFinal, null, activityFinalIconRect, activityFinalTextRect);
registerNode('swimlaneV', swimlaneV, null, swimlaneVIconRect, swimlaneVTextRect);
registerNode('swimlaneH', swimlaneH, null, swimlaneHIconRect, swimlaneHTextRect);
registerNode('forkH', fork, forkHAnchors, forkIconRect, forkTextRect);
registerNode('forkV', fork, forkVAnchors, forkIconRect, forkTextRect);
import { registerNode } from '@topology/core'
import { activityFinal, activityFinalIconRect, activityFinalTextRect } from './final'
import { fork, forkHAnchors, forkVAnchors, forkIconRect, forkTextRect } from './fork'
import { swimlaneH, swimlaneHIconRect, swimlaneHTextRect } from './swimlaneH'
import { swimlaneV, swimlaneVIconRect, swimlaneVTextRect } from './swimlaneV'
export function register () {
registerNode('activityFinal', activityFinal, null, activityFinalIconRect, activityFinalTextRect)
registerNode('swimlaneV', swimlaneV, null, swimlaneVIconRect, swimlaneVTextRect)
registerNode('swimlaneH', swimlaneH, null, swimlaneHIconRect, swimlaneHTextRect)
registerNode('forkH', fork, forkHAnchors, forkIconRect, forkTextRect)
registerNode('forkV', fork, forkVAnchors, forkIconRect, forkTextRect)
}
//# sourceMappingURL=register.js.map
// # sourceMappingURL=register.js.map

View File

@@ -1,3 +1,3 @@
export * from './swimlaneH';
export * from './swimlaneH.rect';
//# sourceMappingURL=index.js.map
export * from './swimlaneH'
export * from './swimlaneH.rect'
// # sourceMappingURL=index.js.map

View File

@@ -1,27 +1,27 @@
export function swimlaneH(ctx, node) {
var wr = node.borderRadius;
var hr = node.borderRadius;
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius;
hr = node.rect.height * node.borderRadius;
}
var r = wr < hr ? wr : hr;
if (node.rect.width < 2 * r) {
r = node.rect.width / 2;
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2;
}
ctx.beginPath();
ctx.moveTo(node.rect.x + r, node.rect.y);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r);
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r);
ctx.closePath();
ctx.moveTo(node.rect.x + 40, node.rect.y);
ctx.lineTo(node.rect.x + 40, node.rect.ey);
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function swimlaneH (ctx, node) {
let wr = node.borderRadius
let hr = node.borderRadius
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius
hr = node.rect.height * node.borderRadius
}
let r = wr < hr ? wr : hr
if (node.rect.width < 2 * r) {
r = node.rect.width / 2
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2
}
ctx.beginPath()
ctx.moveTo(node.rect.x + r, node.rect.y)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r)
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r)
ctx.closePath()
ctx.moveTo(node.rect.x + 40, node.rect.y)
ctx.lineTo(node.rect.x + 40, node.rect.ey);
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=swimlaneH.js.map
// # sourceMappingURL=swimlaneH.js.map

View File

@@ -1,9 +1,9 @@
import { Rect } from '@topology/core';
export function swimlaneHIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
import { Rect } from '@topology/core'
export function swimlaneHIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function swimlaneHTextRect(node) {
node.textRect = new Rect(node.rect.x + 10, node.rect.y, 20, node.rect.height);
node.fullTextRect = node.textRect;
export function swimlaneHTextRect (node) {
node.textRect = new Rect(node.rect.x + 10, node.rect.y, 20, node.rect.height)
node.fullTextRect = node.textRect
}
//# sourceMappingURL=swimlaneH.rect.js.map
// # sourceMappingURL=swimlaneH.rect.js.map

View File

@@ -1,3 +1,3 @@
export * from './swimlaneV';
export * from './swimlaneV.rect';
//# sourceMappingURL=index.js.map
export * from './swimlaneV'
export * from './swimlaneV.rect'
// # sourceMappingURL=index.js.map

View File

@@ -1,27 +1,27 @@
export function swimlaneV(ctx, node) {
var wr = node.borderRadius;
var hr = node.borderRadius;
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius;
hr = node.rect.height * node.borderRadius;
}
var r = wr < hr ? wr : hr;
if (node.rect.width < 2 * r) {
r = node.rect.width / 2;
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2;
}
ctx.beginPath();
ctx.moveTo(node.rect.x + r, node.rect.y);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r);
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r);
ctx.closePath();
ctx.moveTo(node.rect.x, node.rect.y + 40);
ctx.lineTo(node.rect.ex, node.rect.y + 40);
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function swimlaneV (ctx, node) {
let wr = node.borderRadius
let hr = node.borderRadius
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius
hr = node.rect.height * node.borderRadius
}
let r = wr < hr ? wr : hr
if (node.rect.width < 2 * r) {
r = node.rect.width / 2
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2
}
ctx.beginPath()
ctx.moveTo(node.rect.x + r, node.rect.y)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r)
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r)
ctx.closePath()
ctx.moveTo(node.rect.x, node.rect.y + 40)
ctx.lineTo(node.rect.ex, node.rect.y + 40);
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=swimlaneV.js.map
// # sourceMappingURL=swimlaneV.js.map

View File

@@ -1,9 +1,9 @@
import { Rect } from '@topology/core';
export function swimlaneVIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
import { Rect } from '@topology/core'
export function swimlaneVIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function swimlaneVTextRect(node) {
node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40);
node.fullTextRect = node.textRect;
export function swimlaneVTextRect (node) {
node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40)
node.fullTextRect = node.textRect
}
//# sourceMappingURL=swimlaneV.rect.js.map
// # sourceMappingURL=swimlaneV.rect.js.map

View File

@@ -1,3 +1,3 @@
export * from './src/echarts';
export * from './src/register';
//# sourceMappingURL=index.js.map
export * from './src/echarts'
export * from './src/register'
// # sourceMappingURL=index.js.map

View File

@@ -1,44 +1,44 @@
import { s8, createDiv, rectangle } from '@topology/core';
export var echartsObjs = {};
export function echarts(ctx, node) {
// 绘制一个底图,类似于占位符。
rectangle(ctx, node);
// tslint:disable-next-line:no-shadowed-variable
var echarts = echartsObjs.echarts || window.echarts;
if (!node.data || !echarts) {
return;
}
if (typeof node.data === 'string') {
node.data = JSON.parse(node.data);
}
if (!node.data.echarts) {
return;
}
if (!node.elementId) {
node.elementId = s8();
}
if (!node.elementLoaded) {
echartsObjs[node.id] = {
div: createDiv(node),
};
node.elementLoaded = true;
document.body.appendChild(echartsObjs[node.id].div);
// 添加当前节点到div层
node.addToDiv();
echartsObjs[node.id].chart = echarts.init(echartsObjs[node.id].div, node.data.echarts.theme);
node.elementRendered = false;
// 等待父div先渲染完成避免初始图表控件太大
setTimeout(function () {
echartsObjs[node.id].chart.resize();
});
}
if (!node.elementRendered) {
// 初始化时等待父div先渲染完成避免初始图表控件太大。
setTimeout(function () {
echartsObjs[node.id].chart.setOption(node.data.echarts.option);
echartsObjs[node.id].chart.resize();
node.elementRendered = true;
});
import { s8, createDiv, rectangle } from '@topology/core'
export var echartsObjs = {}
export function echarts (ctx, node) {
// 绘制一个底图,类似于占位符。
rectangle(ctx, node)
// tslint:disable-next-line:no-shadowed-variable
const echarts = echartsObjs.echarts || window.echarts
if (!node.data || !echarts) {
return
}
if (typeof node.data === 'string') {
node.data = JSON.parse(node.data)
}
if (!node.data.echarts) {
return
}
if (!node.elementId) {
node.elementId = s8()
}
if (!node.elementLoaded) {
echartsObjs[node.id] = {
div: createDiv(node)
}
node.elementLoaded = true
document.body.appendChild(echartsObjs[node.id].div)
// 添加当前节点到div层
node.addToDiv()
echartsObjs[node.id].chart = echarts.init(echartsObjs[node.id].div, node.data.echarts.theme)
node.elementRendered = false
// 等待父div先渲染完成避免初始图表控件太大
setTimeout(function () {
echartsObjs[node.id].chart.resize()
})
}
if (!node.elementRendered) {
// 初始化时等待父div先渲染完成避免初始图表控件太大。
setTimeout(function () {
echartsObjs[node.id].chart.setOption(node.data.echarts.option)
echartsObjs[node.id].chart.resize()
node.elementRendered = true
})
}
}
//# sourceMappingURL=index.js.map
// # sourceMappingURL=index.js.map

View File

@@ -1,10 +1,10 @@
import { registerNode, loadJS } from '@topology/core';
import { echarts, echartsObjs } from './echarts';
export function register(_echarts) {
echartsObjs.echarts = _echarts;
if (!echartsObjs.echarts && !window.echarts) {
loadJS('https://cdn.bootcdn.net/ajax/libs/echarts/4.8.0/echarts.min.js', null, true);
}
registerNode('echarts', echarts, null, null, null);
import { registerNode, loadJS } from '@topology/core'
import { echarts, echartsObjs } from './echarts'
export function register (_echarts) {
echartsObjs.echarts = _echarts
if (!echartsObjs.echarts && !window.echarts) {
loadJS('https://cdn.bootcdn.net/ajax/libs/echarts/4.8.0/echarts.min.js', null, true)
}
registerNode('echarts', echarts, null, null, null)
}
//# sourceMappingURL=register.js.map
// # sourceMappingURL=register.js.map

View File

@@ -1,3 +1,3 @@
export * from './src/class';
export * from './src/register';
//# sourceMappingURL=index.js.map
export * from './src/class'
export * from './src/register'
// # sourceMappingURL=index.js.map

View File

@@ -1,56 +1,56 @@
export function simpleClass(ctx, node) {
var wr = node.borderRadius;
var hr = node.borderRadius;
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius;
hr = node.rect.height * node.borderRadius;
}
var r = wr < hr ? wr : hr;
if (node.rect.width < 2 * r) {
r = node.rect.width / 2;
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2;
}
ctx.beginPath();
ctx.moveTo(node.rect.x + r, node.rect.y);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r);
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r);
ctx.closePath();
ctx.moveTo(node.rect.x, node.rect.y + 40);
ctx.lineTo(node.rect.ex, node.rect.y + 40);
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function simpleClass (ctx, node) {
let wr = node.borderRadius
let hr = node.borderRadius
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius
hr = node.rect.height * node.borderRadius
}
let r = wr < hr ? wr : hr
if (node.rect.width < 2 * r) {
r = node.rect.width / 2
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2
}
ctx.beginPath()
ctx.moveTo(node.rect.x + r, node.rect.y)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r)
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r)
ctx.closePath()
ctx.moveTo(node.rect.x, node.rect.y + 40)
ctx.lineTo(node.rect.ex, node.rect.y + 40);
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
export function interfaceClass(ctx, node) {
var wr = node.borderRadius;
var hr = node.borderRadius;
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius;
hr = node.rect.height * node.borderRadius;
}
var r = wr < hr ? wr : hr;
if (node.rect.width < 2 * r) {
r = node.rect.width / 2;
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2;
}
ctx.beginPath();
ctx.moveTo(node.rect.x + r, node.rect.y);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r);
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r);
ctx.closePath();
ctx.moveTo(node.rect.x, node.rect.y + 40);
ctx.lineTo(node.rect.ex, node.rect.y + 40);
var height = node.rect.y + 20 + node.rect.height / 2;
ctx.moveTo(node.rect.x, height);
ctx.lineTo(node.rect.ex, height);
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function interfaceClass (ctx, node) {
let wr = node.borderRadius
let hr = node.borderRadius
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius
hr = node.rect.height * node.borderRadius
}
let r = wr < hr ? wr : hr
if (node.rect.width < 2 * r) {
r = node.rect.width / 2
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2
}
ctx.beginPath()
ctx.moveTo(node.rect.x + r, node.rect.y)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r)
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r)
ctx.closePath()
ctx.moveTo(node.rect.x, node.rect.y + 40)
ctx.lineTo(node.rect.ex, node.rect.y + 40)
const height = node.rect.y + 20 + node.rect.height / 2
ctx.moveTo(node.rect.x, height)
ctx.lineTo(node.rect.ex, height);
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=class.js.map
// # sourceMappingURL=class.js.map

View File

@@ -1,16 +1,16 @@
import { Rect } from '@topology/core';
export function simpleClassIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
import { Rect } from '@topology/core'
export function simpleClassIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function simpleClassTextRect(node) {
node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40);
node.fullTextRect = node.textRect;
export function simpleClassTextRect (node) {
node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40)
node.fullTextRect = node.textRect
}
export function interfaceClassIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
export function interfaceClassIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function interfaceClassTextRect(node) {
node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40);
node.fullTextRect = node.textRect;
export function interfaceClassTextRect (node) {
node.textRect = new Rect(node.rect.x, node.rect.y, node.rect.width, 40)
node.fullTextRect = node.textRect
}
//# sourceMappingURL=class.rect.js.map
// # sourceMappingURL=class.rect.js.map

View File

@@ -1,3 +1,3 @@
export * from './class';
export * from './class.rect';
//# sourceMappingURL=index.js.map
export * from './class'
export * from './class.rect'
// # sourceMappingURL=index.js.map

View File

@@ -1,7 +1,7 @@
import { registerNode } from '@topology/core';
import { simpleClass, simpleClassIconRect, simpleClassTextRect, interfaceClass, interfaceClassIconRect, interfaceClassTextRect } from './class';
export function register() {
registerNode('simpleClass', simpleClass, null, simpleClassIconRect, simpleClassTextRect);
registerNode('interfaceClass', interfaceClass, null, interfaceClassIconRect, interfaceClassTextRect);
import { registerNode } from '@topology/core'
import { simpleClass, simpleClassIconRect, simpleClassTextRect, interfaceClass, interfaceClassIconRect, interfaceClassTextRect } from './class'
export function register () {
registerNode('simpleClass', simpleClass, null, simpleClassIconRect, simpleClassTextRect)
registerNode('interfaceClass', interfaceClass, null, interfaceClassIconRect, interfaceClassTextRect)
}
//# sourceMappingURL=register.js.map
// # sourceMappingURL=register.js.map

View File

@@ -1,6 +1,6 @@
export * from './src/core';
export * from './src/options';
export * from './src/utils';
export * from './src/models';
export * from './src/middles';
//# sourceMappingURL=index.js.map
export * from './src/core'
export * from './src/options'
export * from './src/utils'
export * from './src/models'
export * from './src/middles'
// # sourceMappingURL=index.js.map

View File

@@ -1,264 +1,256 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { Store } from 'le5le-store';
import { PenType } from './models/pen';
import { Node } from './models/node';
import { Line } from './models/line';
import { Layer } from './layer';
import { s8 } from './utils/uuid';
import { find } from './utils/canvas';
var AnimateLayer = /** @class */ (function (_super) {
__extends(AnimateLayer, _super);
function AnimateLayer(options, TID) {
if (options === void 0) { options = {}; }
var _this = _super.call(this, TID) || this;
_this.options = options;
_this.pens = new Map();
_this.lastNow = 0;
Store.set(_this.generateStoreKey('LT:AnimateLayer'), _this);
if (!_this.options.animateColor) {
_this.options.animateColor = '#ff6600';
}
_this.subscribeUpdate = Store.subscribe(_this.generateStoreKey('LT:updateLines'), function (lines) {
_this.updateLines(lines);
});
_this.subscribePlay = Store.subscribe(_this.generateStoreKey('LT:AnimatePlay'), function (params) {
if (params.stop) {
if (params.tag) {
var pens = find(params.tag, _this.data.pens);
pens.forEach(function (item) {
if (_this.pens.has(item.id)) {
_this.pens.get(item.id).animateStart = 0;
}
});
}
if (params.pen && _this.pens.has(params.pen.id)) {
_this.pens.get(params.pen.id).animateStart = 0;
}
}
else {
if (params.pen) {
if (_this.pens.has(params.pen.id)) {
_this.pens.get(params.pen.id).animateStart = Date.now();
}
else {
if (params.pen.type) {
_this.pens.set(params.pen.id, _this.getAnimateLine(params.pen));
}
else {
_this.pens.set(params.pen.id, params.pen);
}
}
}
if (params.tag) {
_this.readyPlay(params.tag, false);
}
}
_this.animate();
});
return _this;
import { Store } from 'le5le-store'
import { PenType } from './models/pen'
import { Node } from './models/node'
import { Line } from './models/line'
import { Layer } from './layer'
import { s8 } from './utils/uuid'
import { find } from './utils/canvas'
const __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) ||
function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p] }
return extendStatics(d, b)
}
return function (d, b) {
extendStatics(d, b)
function __ () { this.constructor = d }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __())
}
})()
const AnimateLayer = /** @class */ (function (_super) {
__extends(AnimateLayer, _super)
function AnimateLayer (options, TID) {
if (options === void 0) { options = {} }
const _this = _super.call(this, TID) || this
_this.options = options
_this.pens = new Map()
_this.lastNow = 0
Store.set(_this.generateStoreKey('LT:AnimateLayer'), _this)
if (!_this.options.animateColor) {
_this.options.animateColor = '#ff6600'
}
AnimateLayer.prototype.getAnimateLine = function (item) {
var l = new Line(item);
l.data = l.id;
l.id = s8();
l.setTID(this.TID);
l.isAnimate = true;
l.toArrow = '';
if (l.fromArrow && l.fromArrow.indexOf('line') < 0) {
l.animateFromSize = l.fromArrowSize + l.lineWidth * 5;
_this.subscribeUpdate = Store.subscribe(_this.generateStoreKey('LT:updateLines'), function (lines) {
_this.updateLines(lines)
})
_this.subscribePlay = Store.subscribe(_this.generateStoreKey('LT:AnimatePlay'), function (params) {
if (params.stop) {
if (params.tag) {
const pens = find(params.tag, _this.data.pens)
pens.forEach(function (item) {
if (_this.pens.has(item.id)) {
_this.pens.get(item.id).animateStart = 0
}
})
}
if (l.toArrow && l.toArrow.indexOf('line') < 0) {
l.animateToSize = l.toArrowSize + l.lineWidth * 5;
if (params.pen && _this.pens.has(params.pen.id)) {
_this.pens.get(params.pen.id).animateStart = 0
}
l.animateStart = item.animateStart;
l.lineCap = 'round';
l.fillStyle = '#fff';
l.strokeStyle = l.animateColor || this.options.animateColor;
l.length = l.getLen();
if (!l.fromArrowColor) {
l.fromArrowColor = l.strokeStyle || Store.get(this.generateStoreKey('LT:color'));
} else {
if (params.pen) {
if (_this.pens.has(params.pen.id)) {
_this.pens.get(params.pen.id).animateStart = Date.now()
} else {
if (params.pen.type) {
_this.pens.set(params.pen.id, _this.getAnimateLine(params.pen))
} else {
_this.pens.set(params.pen.id, params.pen)
}
}
}
if (!l.toArrowColor) {
l.toArrowColor = l.strokeStyle || Store.get(this.generateStoreKey('LT:color'));
if (params.tag) {
_this.readyPlay(params.tag, false)
}
return l;
};
AnimateLayer.prototype.findLine = function (pen) {
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
var item = _a[_i];
if (item.id === pen.data) {
return item;
}
}
_this.animate()
})
return _this
}
AnimateLayer.prototype.getAnimateLine = function (item) {
const l = new Line(item)
l.data = l.id
l.id = s8()
l.setTID(this.TID)
l.isAnimate = true
l.toArrow = ''
if (l.fromArrow && l.fromArrow.indexOf('line') < 0) {
l.animateFromSize = l.fromArrowSize + l.lineWidth * 5
}
if (l.toArrow && l.toArrow.indexOf('line') < 0) {
l.animateToSize = l.toArrowSize + l.lineWidth * 5
}
l.animateStart = item.animateStart
l.lineCap = 'round'
l.fillStyle = '#fff'
l.strokeStyle = l.animateColor || this.options.animateColor
l.length = l.getLen()
if (!l.fromArrowColor) {
l.fromArrowColor = l.strokeStyle || Store.get(this.generateStoreKey('LT:color'))
}
if (!l.toArrowColor) {
l.toArrowColor = l.strokeStyle || Store.get(this.generateStoreKey('LT:color'))
}
return l
}
AnimateLayer.prototype.findLine = function (pen) {
for (let _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
const item = _a[_i]
if (item.id === pen.data) {
return item
}
}
}
AnimateLayer.prototype.readyPlay = function (tag, auto, pens) {
const _this = this
const readyPens = new Map()
if (!pens) {
pens = this.data.pens
}
pens.forEach(function (pen) {
pen.setTID(_this.TID)
if (!pen.visible || readyPens.get(pen.id)) {
return
}
if ((auto && pen.animatePlay) || (tag && pen.tags.indexOf(tag) > -1)) {
if (!pen.animateStart || pen.animateStart < 1) {
pen.animateStart = Date.now()
}
};
AnimateLayer.prototype.readyPlay = function (tag, auto, pens) {
var _this = this;
var readyPens = new Map();
if (!pens) {
pens = this.data.pens;
}
if (pen instanceof Node) {
if (pen.animateStart > 0) {
if (!pen.animateReady) {
pen.initAnimate()
}
readyPens.set(pen.id, pen)
}
pens.forEach(function (pen) {
pen.setTID(_this.TID);
if (!pen.visible || readyPens.get(pen.id)) {
return;
}
if ((auto && pen.animatePlay) || (tag && pen.tags.indexOf(tag) > -1)) {
if (!pen.animateStart || pen.animateStart < 1) {
pen.animateStart = Date.now();
}
}
if (pen instanceof Node) {
if (pen.animateStart > 0) {
if (!pen.animateReady) {
pen.initAnimate();
}
readyPens.set(pen.id, pen);
}
if (pen.children && pen.children.length) {
_this.readyPlay(tag, auto, pen.children);
}
}
else {
if (pen.animateStart > 0) {
readyPens.set(pen.id, _this.getAnimateLine(pen));
}
else if (_this.pens.has(pen.id)) {
_this.pens.get(pen.id).animateStart = 0;
}
}
});
readyPens.forEach(function (pen) {
if (pen.type) {
_this.pens.set(pen.data, pen);
}
else {
_this.pens.set(pen.id, pen);
}
});
};
AnimateLayer.prototype.animate = function () {
var _this = this;
if (this.timer) {
cancelAnimationFrame(this.timer);
if (pen.children && pen.children.length) {
_this.readyPlay(tag, auto, pen.children)
}
this.timer = requestAnimationFrame(function () {
var now = Date.now();
if (now - _this.lastNow < _this.options.refresh) {
_this.animate();
return;
}
_this.lastNow = now;
var animated = false;
_this.pens.forEach(function (pen) {
if (!pen.animateStart || pen.animateStart < 1) {
if (pen.type) {
_this.pens.delete(pen.data);
var line = _this.findLine(pen);
if (line) {
line.animateStart = 0;
line.animatePos = pen.animatePos;
}
}
else {
_this.pens.delete(pen.id);
}
return;
}
if (pen.animateStart > now) {
return;
}
if (pen.animateFn) {
if (typeof pen.animateFn === 'function') {
pen.animateFn();
}
else if (window && window[pen.animateFn]) {
window[pen.animateFn]();
}
else {
// pen.render();
}
}
else {
pen.animate(now);
}
if (pen.animateStart < 1) {
if (pen.type) {
_this.pens.delete(pen.data);
}
else {
_this.pens.delete(pen.id);
}
if (pen.type === PenType.Line) {
var line = _this.findLine(pen);
if (line) {
line.animateStart = 0;
line.animatePos = pen.animatePos;
}
}
if (pen.nextAnimate) {
_this.readyPlay(pen.nextAnimate, false);
}
}
animated = true;
});
if (animated) {
Store.set(_this.generateStoreKey('LT:render'), true);
_this.animate();
}
});
};
AnimateLayer.prototype.updateLines = function (lines) {
this.pens.forEach(function (line, key) {
if (!(line instanceof Line)) {
return;
}
for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
var item = lines_1[_i];
if (line.data === item.id) {
line.from = item.from;
line.to = item.to;
line.controlPoints = item.controlPoints;
line.length = line.getLen();
}
}
});
};
AnimateLayer.prototype.render = function (ctx) {
var _this = this;
this.pens.forEach(function (line, key) {
if (line.visible && line instanceof Line) {
if (!line.getTID()) {
line.setTID(_this.TID);
}
line.render(ctx);
}
});
};
AnimateLayer.prototype.stop = function () {
this.pens.clear();
if (this.timer) {
cancelAnimationFrame(this.timer);
this.timer = null;
} else {
if (pen.animateStart > 0) {
readyPens.set(pen.id, _this.getAnimateLine(pen))
} else if (_this.pens.has(pen.id)) {
_this.pens.get(pen.id).animateStart = 0
}
};
AnimateLayer.prototype.destroy = function () {
this.stop();
this.subscribeUpdate.unsubscribe();
this.subscribePlay.unsubscribe();
};
return AnimateLayer;
}(Layer));
export { AnimateLayer };
//# sourceMappingURL=animateLayer.js.map
}
})
readyPens.forEach(function (pen) {
if (pen.type) {
_this.pens.set(pen.data, pen)
} else {
_this.pens.set(pen.id, pen)
}
})
}
AnimateLayer.prototype.animate = function () {
const _this = this
if (this.timer) {
cancelAnimationFrame(this.timer)
}
this.timer = requestAnimationFrame(function () {
const now = Date.now()
if (now - _this.lastNow < _this.options.refresh) {
_this.animate()
return
}
_this.lastNow = now
let animated = false
_this.pens.forEach(function (pen) {
if (!pen.animateStart || pen.animateStart < 1) {
if (pen.type) {
_this.pens.delete(pen.data)
var line = _this.findLine(pen)
if (line) {
line.animateStart = 0
line.animatePos = pen.animatePos
}
} else {
_this.pens.delete(pen.id)
}
return
}
if (pen.animateStart > now) {
return
}
if (pen.animateFn) {
if (typeof pen.animateFn === 'function') {
pen.animateFn()
} else if (window && window[pen.animateFn]) {
window[pen.animateFn]()
} else {
// pen.render();
}
} else {
pen.animate(now)
}
if (pen.animateStart < 1) {
if (pen.type) {
_this.pens.delete(pen.data)
} else {
_this.pens.delete(pen.id)
}
if (pen.type === PenType.Line) {
var line = _this.findLine(pen)
if (line) {
line.animateStart = 0
line.animatePos = pen.animatePos
}
}
if (pen.nextAnimate) {
_this.readyPlay(pen.nextAnimate, false)
}
}
animated = true
})
if (animated) {
Store.set(_this.generateStoreKey('LT:render'), true)
_this.animate()
}
})
}
AnimateLayer.prototype.updateLines = function (lines) {
this.pens.forEach(function (line, key) {
if (!(line instanceof Line)) {
return
}
for (let _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
const item = lines_1[_i]
if (line.data === item.id) {
line.from = item.from
line.to = item.to
line.controlPoints = item.controlPoints
line.length = line.getLen()
}
}
})
}
AnimateLayer.prototype.render = function (ctx) {
const _this = this
this.pens.forEach(function (line, key) {
if (line.visible && line instanceof Line) {
if (!line.getTID()) {
line.setTID(_this.TID)
}
line.render(ctx)
}
})
}
AnimateLayer.prototype.stop = function () {
this.pens.clear()
if (this.timer) {
cancelAnimationFrame(this.timer)
this.timer = null
}
}
AnimateLayer.prototype.destroy = function () {
this.stop()
this.subscribeUpdate.unsubscribe()
this.subscribePlay.unsubscribe()
this.subscribeUpdate = null
this.subscribePlay = null
this.pens = null
}
return AnimateLayer
}(Layer))
export { AnimateLayer }
// # sourceMappingURL=animateLayer.js.map

View File

@@ -1,89 +1,96 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { Store } from 'le5le-store';
import { Layer } from './layer';
var Canvas = /** @class */ (function (_super) {
__extends(Canvas, _super);
function Canvas(parentElem, options, TID) {
if (options === void 0) { options = {}; }
var _this = _super.call(this, TID) || this;
_this.parentElem = parentElem;
_this.options = options;
_this.canvas = document.createElement('canvas');
_this.width = 0;
_this.height = 0;
_this.subcribe = Store.subscribe(_this.generateStoreKey('topology-data'), function (val) {
_this.data = val;
});
_this.canvas.style.position = 'absolute';
_this.canvas.style.left = '0';
_this.canvas.style.top = '0';
_this.canvas.style.outline = 'none';
if (!Canvas.dpiRatio) {
if (!options.extDpiRatio && options.extDpiRatio !== 0) {
if (window && window.devicePixelRatio > 1) {
options.extDpiRatio = 0.25;
}
else {
options.extDpiRatio = 0;
}
}
Canvas.dpiRatio = (window ? window.devicePixelRatio : 0) + options.extDpiRatio;
if (Canvas.dpiRatio < 1) {
Canvas.dpiRatio = 1;
}
import { Store } from 'le5le-store'
import { Layer } from './layer'
const __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) ||
function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p] }
return extendStatics(d, b)
}
return function (d, b) {
extendStatics(d, b)
function __ () { this.constructor = d }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __())
}
})()
const Canvas = /** @class */ (function (_super) {
__extends(Canvas, _super)
function Canvas (parentElem, options, TID) {
if (options === void 0) { options = {} }
const _this = _super.call(this, TID) || this
_this.parentElem = parentElem
_this.options = options
_this.canvas = document.createElement('canvas')
_this.width = 0
_this.height = 0
_this.subcribe = Store.subscribe(_this.generateStoreKey('topology-data'), function (val) {
_this.data = val
})
_this.canvas.style.position = 'absolute'
_this.canvas.style.left = '0'
_this.canvas.style.top = '0'
_this.canvas.style.outline = 'none'
if (!Canvas.dpiRatio) {
if (!options.extDpiRatio && options.extDpiRatio !== 0) {
if (window && window.devicePixelRatio > 1) {
options.extDpiRatio = 0.25
} else {
options.extDpiRatio = 0
}
return _this;
}
Canvas.dpiRatio = (window ? window.devicePixelRatio : 0) + options.extDpiRatio
if (Canvas.dpiRatio < 1) {
Canvas.dpiRatio = 1
}
}
Canvas.prototype.resize = function (size) {
if (size) {
this.width = size.width | 0;
this.height = size.height | 0;
}
else {
if (this.options.width && this.options.width !== 'auto') {
this.width = +this.options.width;
}
else {
this.width = this.parentElem.clientWidth;
}
if (this.options.height && this.options.height !== 'auto') {
this.height = +this.options.height;
}
else {
this.height = this.parentElem.clientHeight;
}
}
this.canvas.style.width = this.width + 'px';
this.canvas.style.height = this.height + 'px';
this.canvas.width = (this.width * Canvas.dpiRatio) | 0;
this.canvas.height = (this.height * Canvas.dpiRatio) | 0;
this.canvas.getContext('2d').scale(Canvas.dpiRatio, Canvas.dpiRatio);
Store.set(this.generateStoreKey('LT:size'), { width: this.canvas.width, height: this.canvas.height });
};
Canvas.prototype.render = function () {
var ctx = this.canvas.getContext('2d');
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
};
Canvas.prototype.getDpiRatio = function () {
return Canvas.dpiRatio;
};
Canvas.prototype.destroy = function () {
this.subcribe.unsubscribe();
};
Canvas.dpiRatio = 0;
return Canvas;
}(Layer));
export { Canvas };
//# sourceMappingURL=canvas.js.map
return _this
}
Canvas.prototype.resize = function (size) {
if (size) {
this.width = size.width | 0
this.height = size.height | 0
} else {
if (this.options.width && this.options.width !== 'auto') {
this.width = +this.options.width
} else {
this.width = this.parentElem.clientWidth
}
if (this.options.height && this.options.height !== 'auto') {
this.height = +this.options.height
} else {
this.height = this.parentElem.clientHeight
}
}
this.canvas.style.width = this.width + 'px'
this.canvas.style.height = this.height + 'px'
this.canvas.width = (this.width * Canvas.dpiRatio) | 0
this.canvas.height = (this.height * Canvas.dpiRatio) | 0
this.canvas.getContext('2d').scale(Canvas.dpiRatio, Canvas.dpiRatio)
Store.set(this.generateStoreKey('LT:size'), { width: this.canvas.width, height: this.canvas.height })
}
Canvas.prototype.render = function () {
const ctx = this.canvas.getContext('2d')
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)
}
Canvas.prototype.getDpiRatio = function () {
return Canvas.dpiRatio
}
Canvas.prototype.destroy = function () {
this.subcribe.unsubscribe()
this.activeLayer = null
this.hoverLayer = null
this.animateLayer = null
this.subcribe = null
this.options = null
this.parentElem = null
this.data = null
this.offscreen = null
this.canvas = null
this.bkImg = null
this.render = null
}
Canvas.dpiRatio = 0
return Canvas
}(Layer))
export { Canvas }
// # sourceMappingURL=canvas.js.map

View File

@@ -86,6 +86,7 @@ const Topology = /** @class */ (function () {
}
timer = setTimeout(function () {
_this.resize()
timer = null
}, 100)
}
this.calibrateMouse = function (pt) {
@@ -819,17 +820,17 @@ const Topology = /** @class */ (function () {
Store.set(this.generateStoreKey('LT:fontColor'), this.options.fontColor || '#222222')
this.setupDom(parent)
this.setupSubscribe()
this.setupMouseEvent()
// this.setupMouseEvent()
// Wait for parent dom load
setTimeout(function () {
_this.canvasPos = _this.divLayer.canvas.getBoundingClientRect()
}, 500)
setTimeout(function () {
_this.canvasPos = _this.divLayer.canvas.getBoundingClientRect()
}, 1000)
this.cache()
// setTimeout(function () {
// _this.canvasPos = _this.divLayer.canvas.getBoundingClientRect()
// }, 500)
// setTimeout(function () {
// _this.canvasPos = _this.divLayer.canvas.getBoundingClientRect()
// }, 1000)
// this.cache()
window.topology = this
this.dispatch('loaded')
// this.dispatch('loaded')
}
Object.defineProperty(Topology.prototype, 'ramCaches', {
// 内存中的 caches 数量
@@ -1917,7 +1918,7 @@ const Topology = /** @class */ (function () {
return offset
}
Topology.prototype.cache = function () {
if (this.options.cacheLen == 0 || this.data.locked) { return }
if (this.options.cacheLen == 0 || this.data && this.data.locked) { return }
if (this.caches.index < this.caches.list.length - 1) {
this.caches.list.splice(this.caches.index + 1, this.caches.list.length - this.caches.index - 1)
// 删除 indexDB 的值
@@ -2964,7 +2965,7 @@ const Topology = /** @class */ (function () {
this.activeLayer.destroy()
this.hoverLayer.destroy()
this.offscreen.destroy()
document.body.removeChild(this.tipMarkdown)
// document.body.removeChild(this.tipMarkdown)
window.removeEventListener('resize', this.winResize)
this.parentElem.removeEventListener('scroll', this.onScroll)
window.removeEventListener('scroll', this.onScroll)
@@ -2987,9 +2988,6 @@ const Topology = /** @class */ (function () {
this.data = null
console.log(this.options)
window.topology = null
createCacheTable()
this.divLayer.clear()
this.activeLayer = null
this.activeLayer = null
this.hoverLayer = null
this.animateLayer = null
@@ -3001,11 +2999,18 @@ const Topology = /** @class */ (function () {
this.subcribeAnimateMoved = null
this.subcribeEmit = null
this.offscreen = null
this.parentElem.onresize = null
this.parentElem = null
this.input = null
this.data = null
this.caches = null
this.clipboard = null
this.gifs = {}
this.gifs = null
this.tipMarkdown = null
this.tipMarkdownContent = null
this.tipMarkdownArrowUp = null
this.tipMarkdownArrowDown = null
delete this
}
return Topology
}())

View File

@@ -1,211 +1,211 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { PenType } from './models/pen';
import { Store } from 'le5le-store';
import { Lock } from './models/status';
import { Layer } from './layer';
import { rgba } from './utils/math';
var HoverLayer = /** @class */ (function (_super) {
__extends(HoverLayer, _super);
function HoverLayer(options, TID) {
if (options === void 0) { options = {}; }
var _this = _super.call(this, TID) || this;
_this.options = options;
_this.hoverAnchorIndex = -1;
_this.dockLineX = 0;
_this.dockLineY = 0;
Store.set(_this.generateStoreKey('LT:HoverLayer'), _this);
return _this;
import { PenType } from './models/pen'
import { Store } from 'le5le-store'
import { Lock } from './models/status'
import { Layer } from './layer'
import { rgba } from './utils/math'
const __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) ||
function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p] }
return extendStatics(d, b)
}
return function (d, b) {
extendStatics(d, b)
function __ () { this.constructor = d }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __())
}
})()
const HoverLayer = /** @class */ (function (_super) {
__extends(HoverLayer, _super)
function HoverLayer (options, TID) {
if (options === void 0) { options = {} }
const _this = _super.call(this, TID) || this
_this.options = options
_this.hoverAnchorIndex = -1
_this.dockLineX = 0
_this.dockLineY = 0
Store.set(_this.generateStoreKey('LT:HoverLayer'), _this)
return _this
}
HoverLayer.prototype.lineTo = function (to, toArrow) {
if (toArrow === void 0) { toArrow = 'triangleSolid' }
if (!this.line || this.line.locked) {
return
}
HoverLayer.prototype.lineTo = function (to, toArrow) {
if (toArrow === void 0) { toArrow = 'triangleSolid'; }
if (!this.line || this.line.locked) {
return;
this.line.setTo(to, toArrow)
if (this.line.from.id || this.line.to.id) {
this.line.calcControlPoints()
}
Store.set(this.generateStoreKey('pts-') + this.line.id, undefined)
Store.set(this.generateStoreKey('LT:updateLines'), [this.line])
}
HoverLayer.prototype.lineFrom = function (from) {
if (this.line.locked) {
return
}
this.line.setFrom(from, this.line.fromArrow)
if (this.line.from.id || this.line.to.id) {
this.line.calcControlPoints()
}
Store.set(this.generateStoreKey('pts-') + this.line.id, undefined)
Store.set(this.generateStoreKey('LT:updateLines'), [this.line])
}
HoverLayer.prototype.render = function (ctx) {
const _this = this
if (this.data.locked === Lock.NoEvent || this.options.hoverColor === 'transparent') {
return
}
ctx.fillStyle = this.options.hoverColor
ctx.save()
// anchors
if (this.options.alwaysAnchor) {
this.data.pens.forEach(function (pen) {
if (pen.type === PenType.Line) {
return
}
this.line.setTo(to, toArrow);
if (this.line.from.id || this.line.to.id) {
this.line.calcControlPoints();
if (pen.hideAnchor) {
return
}
Store.set(this.generateStoreKey('pts-') + this.line.id, undefined);
Store.set(this.generateStoreKey('LT:updateLines'), [this.line]);
};
HoverLayer.prototype.lineFrom = function (from) {
if (this.line.locked) {
return;
for (let _i = 0, _a = pen.rotatedAnchors; _i < _a.length; _i++) {
const anchor = _a[_i]
if (anchor.hidden) {
continue
}
ctx.beginPath()
ctx.arc(anchor.x, anchor.y, anchor.radius || _this.options.anchorRadius, 0, Math.PI * 2)
ctx.strokeStyle = anchor.strokeStyle || _this.options.hoverColor
ctx.fillStyle = anchor.fillStyle || _this.options.anchorFillStyle
ctx.fill()
ctx.stroke()
}
this.line.setFrom(from, this.line.fromArrow);
if (this.line.from.id || this.line.to.id) {
this.line.calcControlPoints();
if (_this.options.autoAnchor) {
ctx.beginPath()
ctx.arc(pen.rect.center.x, pen.rect.center.y, pen.rect.center.radius || _this.options.anchorRadius, 0, Math.PI * 2)
ctx.strokeStyle = _this.options.hoverColor
ctx.fillStyle = _this.options.anchorFillStyle
ctx.fill()
ctx.stroke()
}
Store.set(this.generateStoreKey('pts-') + this.line.id, undefined);
Store.set(this.generateStoreKey('LT:updateLines'), [this.line]);
};
HoverLayer.prototype.render = function (ctx) {
var _this = this;
if (this.data.locked === Lock.NoEvent || this.options.hoverColor === 'transparent') {
return;
})
}
ctx.restore()
if (this.node && !this.data.locked) {
if (!this.node.getTID()) {
this.node.setTID(this.TID)
}
this.root = this.getRoot(this.node) || this.node
if (this.root) {
ctx.save()
ctx.strokeStyle = this.options.dragColor
ctx.globalAlpha = 0.2
if (this.root.rotate) {
ctx.translate(this.root.rect.center.x, this.root.rect.center.y)
ctx.rotate(((this.root.rotate + this.root.offsetRotate) * Math.PI) / 180)
ctx.translate(-this.root.rect.center.x, -this.root.rect.center.y)
}
ctx.fillStyle = this.options.hoverColor;
ctx.save();
// anchors
if (this.options.alwaysAnchor) {
this.data.pens.forEach(function (pen) {
if (pen.type === PenType.Line) {
return;
}
if (pen.hideAnchor) {
return;
}
for (var _i = 0, _a = pen.rotatedAnchors; _i < _a.length; _i++) {
var anchor = _a[_i];
if (anchor.hidden) {
continue;
}
ctx.beginPath();
ctx.arc(anchor.x, anchor.y, anchor.radius || _this.options.anchorRadius, 0, Math.PI * 2);
ctx.strokeStyle = anchor.strokeStyle || _this.options.hoverColor;
ctx.fillStyle = anchor.fillStyle || _this.options.anchorFillStyle;
ctx.fill();
ctx.stroke();
}
if (_this.options.autoAnchor) {
ctx.beginPath();
ctx.arc(pen.rect.center.x, pen.rect.center.y, pen.rect.center.radius || _this.options.anchorRadius, 0, Math.PI * 2);
ctx.strokeStyle = _this.options.hoverColor;
ctx.fillStyle = _this.options.anchorFillStyle;
ctx.fill();
ctx.stroke();
}
});
}
ctx.restore();
if (this.node && !this.data.locked) {
if (!this.node.getTID()) {
this.node.setTID(this.TID);
}
this.root = this.getRoot(this.node) || this.node;
if (this.root) {
ctx.save();
ctx.strokeStyle = this.options.dragColor;
ctx.globalAlpha = 0.2;
if (this.root.rotate) {
ctx.translate(this.root.rect.center.x, this.root.rect.center.y);
ctx.rotate(((this.root.rotate + this.root.offsetRotate) * Math.PI) / 180);
ctx.translate(-this.root.rect.center.x, -this.root.rect.center.y);
}
ctx.beginPath();
ctx.strokeRect(this.root.rect.x, this.root.rect.y, this.root.rect.width, this.root.rect.height);
ctx.restore();
}
if (!this.options.hideAnchor) {
for (var i = 0; i < this.node.rotatedAnchors.length; ++i) {
if (this.node.locked ||
ctx.beginPath()
ctx.strokeRect(this.root.rect.x, this.root.rect.y, this.root.rect.width, this.root.rect.height)
ctx.restore()
}
if (!this.options.hideAnchor) {
for (let i = 0; i < this.node.rotatedAnchors.length; ++i) {
if (this.node.locked ||
this.node.hideAnchor ||
(this.node.rotatedAnchors[i].hidden && this.hoverAnchorIndex !== i)) {
continue;
}
ctx.beginPath();
ctx.arc(this.node.rotatedAnchors[i].x, this.node.rotatedAnchors[i].y, this.node.rotatedAnchors[i].radius || this.options.anchorRadius, 0, Math.PI * 2);
ctx.strokeStyle = this.node.rotatedAnchors[i].strokeStyle || this.options.hoverColor;
ctx.fillStyle = this.node.rotatedAnchors[i].fillStyle || this.options.anchorFillStyle;
ctx.fill();
ctx.stroke();
}
}
if (this.options.autoAnchor) {
ctx.beginPath();
ctx.arc(this.node.rect.center.x, this.node.rect.center.y, this.node.rect.center.radius || this.options.anchorRadius, 0, Math.PI * 2);
ctx.strokeStyle = this.options.hoverColor;
ctx.fillStyle = this.options.anchorFillStyle;
ctx.fill();
ctx.stroke();
}
continue
}
ctx.beginPath()
ctx.arc(this.node.rotatedAnchors[i].x, this.node.rotatedAnchors[i].y, this.node.rotatedAnchors[i].radius || this.options.anchorRadius, 0, Math.PI * 2)
ctx.strokeStyle = this.node.rotatedAnchors[i].strokeStyle || this.options.hoverColor
ctx.fillStyle = this.node.rotatedAnchors[i].fillStyle || this.options.anchorFillStyle
ctx.fill()
ctx.stroke()
}
if (this.line && !this.data.locked) {
this.root = this.getRoot(this.line);
if (this.root) {
ctx.save();
ctx.strokeStyle = this.options.dragColor;
ctx.globalAlpha = 0.2;
if (this.root.rotate) {
ctx.translate(this.root.rect.center.x, this.root.rect.center.y);
ctx.rotate(((this.root.rotate + this.root.offsetRotate) * Math.PI) / 180);
ctx.translate(-this.root.rect.center.x, -this.root.rect.center.y);
}
ctx.beginPath();
ctx.strokeRect(this.root.rect.x, this.root.rect.y, this.root.rect.width, this.root.rect.height);
ctx.restore();
}
}
if (this.options.autoAnchor) {
ctx.beginPath()
ctx.arc(this.node.rect.center.x, this.node.rect.center.y, this.node.rect.center.radius || this.options.anchorRadius, 0, Math.PI * 2)
ctx.strokeStyle = this.options.hoverColor
ctx.fillStyle = this.options.anchorFillStyle
ctx.fill()
ctx.stroke()
}
}
if (this.line && !this.data.locked) {
this.root = this.getRoot(this.line)
if (this.root) {
ctx.save()
ctx.strokeStyle = this.options.dragColor
ctx.globalAlpha = 0.2
if (this.root.rotate) {
ctx.translate(this.root.rect.center.x, this.root.rect.center.y)
ctx.rotate(((this.root.rotate + this.root.offsetRotate) * Math.PI) / 180)
ctx.translate(-this.root.rect.center.x, -this.root.rect.center.y)
}
if (this.dockAnchor) {
ctx.save();
ctx.beginPath();
ctx.arc(this.dockAnchor.x, this.dockAnchor.y, this.dockAnchor.radius || this.options.anchorRadius, 0, Math.PI * 2);
ctx.strokeStyle = this.options.dockStrokeStyle;
ctx.fillStyle = this.options.dockFillStyle;
ctx.fill();
ctx.stroke();
ctx.restore();
}
if (this.hoverLineCP) {
ctx.beginPath();
ctx.arc(this.hoverLineCP.x, this.hoverLineCP.y, 5, 0, Math.PI * 2);
ctx.fill();
}
ctx.strokeStyle = rgba(0.5, this.options.hoverColor);
ctx.lineWidth = 1;
if (this.dockLineX > 0) {
var size = Store.get(this.generateStoreKey('LT:size'));
ctx.beginPath();
ctx.moveTo(this.dockLineX, -this.data.y);
ctx.lineTo(this.dockLineX, size.height);
ctx.stroke();
}
if (this.dockLineY > 0) {
var size = Store.get(this.generateStoreKey('LT:size'));
ctx.beginPath();
ctx.moveTo(-this.data.x, this.dockLineY);
ctx.lineTo(size.width, this.dockLineY);
ctx.stroke();
}
// Select nodes by drag.
if (this.dragRect) {
ctx.fillStyle = rgba(0.2, this.options.dragColor);
ctx.strokeStyle = this.options.dragColor;
ctx.beginPath();
ctx.strokeRect(this.dragRect.x, this.dragRect.y, this.dragRect.width, this.dragRect.height);
ctx.fillRect(this.dragRect.x, this.dragRect.y, this.dragRect.width, this.dragRect.height);
}
};
HoverLayer.prototype.getRoot = function (pen) {
if (!pen.parentId) {
return null;
}
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
var item = _a[_i];
if (item.id === pen.parentId) {
var n = this.getRoot(item);
return n ? n : item;
}
}
return null;
};
HoverLayer.prototype.clear = function () {
this.node = undefined;
this.line = undefined;
};
return HoverLayer;
}(Layer));
export { HoverLayer };
//# sourceMappingURL=hoverLayer.js.map
ctx.beginPath()
ctx.strokeRect(this.root.rect.x, this.root.rect.y, this.root.rect.width, this.root.rect.height)
ctx.restore()
}
}
if (this.dockAnchor) {
ctx.save()
ctx.beginPath()
ctx.arc(this.dockAnchor.x, this.dockAnchor.y, this.dockAnchor.radius || this.options.anchorRadius, 0, Math.PI * 2)
ctx.strokeStyle = this.options.dockStrokeStyle
ctx.fillStyle = this.options.dockFillStyle
ctx.fill()
ctx.stroke()
ctx.restore()
}
if (this.hoverLineCP) {
ctx.beginPath()
ctx.arc(this.hoverLineCP.x, this.hoverLineCP.y, 5, 0, Math.PI * 2)
ctx.fill()
}
ctx.strokeStyle = rgba(0.5, this.options.hoverColor)
ctx.lineWidth = 1
if (this.dockLineX > 0) {
var size = Store.get(this.generateStoreKey('LT:size'))
ctx.beginPath()
ctx.moveTo(this.dockLineX, -this.data.y)
ctx.lineTo(this.dockLineX, size.height)
ctx.stroke()
}
if (this.dockLineY > 0) {
var size = Store.get(this.generateStoreKey('LT:size'))
ctx.beginPath()
ctx.moveTo(-this.data.x, this.dockLineY)
ctx.lineTo(size.width, this.dockLineY)
ctx.stroke()
}
// Select nodes by drag.
if (this.dragRect) {
ctx.fillStyle = rgba(0.2, this.options.dragColor)
ctx.strokeStyle = this.options.dragColor
ctx.beginPath()
ctx.strokeRect(this.dragRect.x, this.dragRect.y, this.dragRect.width, this.dragRect.height)
ctx.fillRect(this.dragRect.x, this.dragRect.y, this.dragRect.width, this.dragRect.height)
}
}
HoverLayer.prototype.getRoot = function (pen) {
if (!pen.parentId) {
return null
}
for (let _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
const item = _a[_i]
if (item.id === pen.parentId) {
const n = this.getRoot(item)
return n || item
}
}
return null
}
HoverLayer.prototype.clear = function () {
this.node = undefined
this.line = undefined
}
return HoverLayer
}(Layer))
export { HoverLayer }
// # sourceMappingURL=hoverLayer.js.map

View File

@@ -1,19 +1,20 @@
import { Store } from 'le5le-store';
var Layer = /** @class */ (function () {
function Layer(TID) {
var _this = this;
this.TID = TID;
this.subcribe = Store.subscribe(this.generateStoreKey('topology-data'), function (val) {
_this.data = val;
});
}
Layer.prototype.generateStoreKey = function (key) {
return this.TID + "-" + key;
};
Layer.prototype.destroy = function () {
this.subcribe.unsubscribe();
};
return Layer;
}());
export { Layer };
//# sourceMappingURL=layer.js.map
import { Store } from 'le5le-store'
const Layer = /** @class */ (function () {
function Layer (TID) {
const _this = this
this.TID = TID
this.subcribe = Store.subscribe(this.generateStoreKey('topology-data'), function (val) {
_this.data = val
})
}
Layer.prototype.generateStoreKey = function (key) {
return this.TID + '-' + key
}
Layer.prototype.destroy = function () {
this.subcribe.unsubscribe()
this.subcribe = null
}
return Layer
}())
export { Layer }
// # sourceMappingURL=layer.js.map

View File

@@ -1,24 +1,23 @@
import { Store } from 'le5le-store';
export function circleSolid(ctx, from, to, size, fillStyle) {
size += ctx.lineWidth * 3;
var r = size / 2;
if (ctx.lineWidth < 2) {
ctx.lineWidth = 2;
}
ctx.translate(to.x, to.y);
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x));
ctx.translate(-to.x, -to.y - ctx.lineWidth / 10);
ctx.arc(to.x - r - ctx.lineWidth / 2, to.y, r, 0, 2 * Math.PI);
ctx.stroke();
if (fillStyle) {
ctx.fillStyle = fillStyle;
}
else {
ctx.fillStyle = ctx.strokeStyle;
}
ctx.fill();
import { Store } from 'le5le-store'
export function circleSolid (ctx, from, to, size, fillStyle) {
size += ctx.lineWidth * 3
const r = size / 2
if (ctx.lineWidth < 2) {
ctx.lineWidth = 2
}
ctx.translate(to.x, to.y)
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x))
ctx.translate(-to.x, -to.y - ctx.lineWidth / 10)
ctx.arc(to.x - r - ctx.lineWidth / 2, to.y, r, 0, 2 * Math.PI)
ctx.stroke()
if (fillStyle) {
ctx.fillStyle = fillStyle
} else {
ctx.fillStyle = ctx.strokeStyle
}
ctx.fill()
}
export function circle(ctx, from, to, size) {
circleSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff');
export function circle (ctx, from, to, size) {
circleSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff')
}
//# sourceMappingURL=circle.js.map
// # sourceMappingURL=circle.js.map

View File

@@ -1,32 +1,31 @@
import { Store } from 'le5le-store';
export function diamondSolid(ctx, from, to, size, fillStyle) {
size += ctx.lineWidth * 3;
var r = size / 2;
var arrowWidth = ctx.lineWidth / 10;
if (ctx.lineWidth < 2) {
ctx.lineWidth = 2;
arrowWidth = 0;
}
ctx.translate(to.x, to.y);
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x));
ctx.translate(-to.x - ctx.lineWidth + arrowWidth * 5, -to.y);
ctx.moveTo(to.x, to.y + arrowWidth);
ctx.lineTo(to.x, to.y - arrowWidth);
ctx.lineTo(to.x - r, to.y - r / 2);
ctx.lineTo(to.x - size, to.y - arrowWidth);
ctx.lineTo(to.x - size, to.y + arrowWidth);
ctx.lineTo(to.x - r, to.y + r / 2);
ctx.closePath();
ctx.stroke();
if (fillStyle) {
ctx.fillStyle = fillStyle;
}
else {
ctx.fillStyle = ctx.strokeStyle;
}
ctx.fill();
import { Store } from 'le5le-store'
export function diamondSolid (ctx, from, to, size, fillStyle) {
size += ctx.lineWidth * 3
const r = size / 2
let arrowWidth = ctx.lineWidth / 10
if (ctx.lineWidth < 2) {
ctx.lineWidth = 2
arrowWidth = 0
}
ctx.translate(to.x, to.y)
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x))
ctx.translate(-to.x - ctx.lineWidth + arrowWidth * 5, -to.y)
ctx.moveTo(to.x, to.y + arrowWidth)
ctx.lineTo(to.x, to.y - arrowWidth)
ctx.lineTo(to.x - r, to.y - r / 2)
ctx.lineTo(to.x - size, to.y - arrowWidth)
ctx.lineTo(to.x - size, to.y + arrowWidth)
ctx.lineTo(to.x - r, to.y + r / 2)
ctx.closePath()
ctx.stroke()
if (fillStyle) {
ctx.fillStyle = fillStyle
} else {
ctx.fillStyle = ctx.strokeStyle
}
ctx.fill()
}
export function diamond(ctx, from, to, size) {
diamondSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff');
export function diamond (ctx, from, to, size) {
diamondSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff')
}
//# sourceMappingURL=diamond.js.map
// # sourceMappingURL=diamond.js.map

View File

@@ -1,42 +1,40 @@
export function line(ctx, from, to, size) {
size += ctx.lineWidth * 3;
ctx.translate(to.x, to.y);
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x));
ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5);
ctx.moveTo(to.x, to.y);
ctx.lineTo(to.x - size, to.y - size / 3);
ctx.moveTo(to.x, to.y);
ctx.lineTo(to.x - size, to.y + size / 3);
ctx.stroke();
export function line (ctx, from, to, size) {
size += ctx.lineWidth * 3
ctx.translate(to.x, to.y)
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x))
ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5)
ctx.moveTo(to.x, to.y)
ctx.lineTo(to.x - size, to.y - size / 3)
ctx.moveTo(to.x, to.y)
ctx.lineTo(to.x - size, to.y + size / 3)
ctx.stroke()
}
export function lineUp(ctx, from, to, size) {
size += ctx.lineWidth * 3;
ctx.translate(to.x, to.y);
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x));
ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5);
if (to.x > from.x) {
ctx.moveTo(to.x, to.y);
ctx.lineTo(to.x - size, to.y - size / 3);
}
else {
ctx.moveTo(to.x, to.y);
ctx.lineTo(to.x - size, to.y + size / 3);
}
ctx.stroke();
export function lineUp (ctx, from, to, size) {
size += ctx.lineWidth * 3
ctx.translate(to.x, to.y)
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x))
ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5)
if (to.x > from.x) {
ctx.moveTo(to.x, to.y)
ctx.lineTo(to.x - size, to.y - size / 3)
} else {
ctx.moveTo(to.x, to.y)
ctx.lineTo(to.x - size, to.y + size / 3)
}
ctx.stroke()
}
export function lineDown(ctx, from, to, size) {
size += ctx.lineWidth * 3;
ctx.translate(to.x, to.y);
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x));
ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5);
if (to.x < from.x) {
ctx.moveTo(to.x, to.y);
ctx.lineTo(to.x - size, to.y - size / 3);
}
else {
ctx.moveTo(to.x, to.y);
ctx.lineTo(to.x - size, to.y + size / 3);
}
ctx.stroke();
export function lineDown (ctx, from, to, size) {
size += ctx.lineWidth * 3
ctx.translate(to.x, to.y)
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x))
ctx.translate(-to.x - ctx.lineWidth / 5, -to.y - ctx.lineWidth / 5)
if (to.x < from.x) {
ctx.moveTo(to.x, to.y)
ctx.lineTo(to.x - size, to.y - size / 3)
} else {
ctx.moveTo(to.x, to.y)
ctx.lineTo(to.x - size, to.y + size / 3)
}
ctx.stroke()
}
//# sourceMappingURL=line.js.map
// # sourceMappingURL=line.js.map

View File

@@ -1,29 +1,28 @@
import { Store } from 'le5le-store';
export function triangleSolid(ctx, from, to, size, fillStyle) {
size += ctx.lineWidth * 3;
var arrowWidth = ctx.lineWidth / 10;
if (ctx.lineWidth < 2) {
ctx.lineWidth = 2;
arrowWidth = 0;
}
ctx.translate(to.x, to.y);
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x));
ctx.translate(-to.x - ctx.lineWidth + arrowWidth * 5, -to.y);
ctx.moveTo(to.x, to.y + arrowWidth);
ctx.lineTo(to.x, to.y - arrowWidth);
ctx.lineTo(to.x - size, to.y - size / 3);
ctx.lineTo(to.x - size, to.y + size / 3);
ctx.closePath();
ctx.stroke();
if (fillStyle) {
ctx.fillStyle = fillStyle;
}
else {
ctx.fillStyle = ctx.strokeStyle;
}
ctx.fill();
import { Store } from 'le5le-store'
export function triangleSolid (ctx, from, to, size, fillStyle) {
size += ctx.lineWidth * 3
let arrowWidth = ctx.lineWidth / 10
if (ctx.lineWidth < 2) {
ctx.lineWidth = 2
arrowWidth = 0
}
ctx.translate(to.x, to.y)
ctx.rotate(Math.atan2(to.y - from.y, to.x - from.x))
ctx.translate(-to.x - ctx.lineWidth + arrowWidth * 5, -to.y)
ctx.moveTo(to.x, to.y + arrowWidth)
ctx.lineTo(to.x, to.y - arrowWidth)
ctx.lineTo(to.x - size, to.y - size / 3)
ctx.lineTo(to.x - size, to.y + size / 3)
ctx.closePath()
ctx.stroke()
if (fillStyle) {
ctx.fillStyle = fillStyle
} else {
ctx.fillStyle = ctx.strokeStyle
}
ctx.fill()
}
export function triangle(ctx, from, to, size) {
triangleSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff');
export function triangle (ctx, from, to, size) {
triangleSolid(ctx, from, to, size, Store.get('LT:bkColor') || '#fff')
}
//# sourceMappingURL=triangle.js.map
// # sourceMappingURL=triangle.js.map

View File

@@ -1,9 +1,9 @@
import { Point } from '../models/point';
import { Direction } from '../models/direction';
export function defaultAnchors(node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up));
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom));
import { Point } from '../models/point'
import { Direction } from '../models/direction'
export function defaultAnchors (node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left))
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up))
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right))
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom))
}
//# sourceMappingURL=default.anchor.js.map
// # sourceMappingURL=default.anchor.js.map

View File

@@ -1,213 +1,213 @@
import { rectangle } from './nodes/rectangle';
import { circle } from './nodes/circle';
import { triangle } from './nodes/triangle';
import { diamond } from './nodes/diamond';
import { leftArrow, rightArrow, twowayArrow } from './nodes/arrow';
import { text } from './nodes/text';
import { line as nodeLine } from './nodes/line';
import { triangleAnchors } from './nodes/triangle.anchor';
import { arrowAnchors } from './nodes/arrow.anchor';
import { lineAnchors } from './nodes/line.anchor';
import { circleIconRect, circleTextRect } from './nodes/circle.rect';
import { triangleIconRect, triangleTextRect } from './nodes/triangle.rect';
import { diamondIconRect, diamondTextRect } from './nodes/diamond.rect';
import { twowayArrowIconRect, twowayArrowTextRect, leftArrowIconRect, leftArrowTextRect, rightArrowIconRect, rightArrowTextRect, } from './nodes/arrow.rect';
import { lineIconRect, lineTextRect } from './nodes/line.rect';
import { line, lineControlPoints, calcLineControlPoints } from './lines/line';
import { polyline, polylineControlPoints, pointInPolyline, calcPolylineControlPoints, dockPolylineControlPoint, } from './lines/polyline';
import { curve, curveControlPoints, pointInCurve, calcCurveControlPoints, } from './lines/curve';
import { calcMindControlPoints, } from './lines/mind';
import { triangleSolid, triangle as arrowTriangle } from './arrows/triangle';
import { diamondSolid, diamond as arrowDiamond } from './arrows/diamond';
import { circleSolid, circle as arrowCircle } from './arrows/circle';
import { circleAnchors } from './nodes/circle.anchor';
import { lineUp, lineDown, line as arrowLine } from './arrows/line';
import { pentagon } from './nodes/pentagon';
import { pentagonIconRect, pentagonTextRect } from './nodes/pentagon.rect';
import { pentagonAnchors } from './nodes/pentagon.anchor';
import { hexagon } from './nodes/hexagon';
import { hexagonAnchors } from './nodes/hexagon.anchor';
import { hexagonIconRect, hexagonTextRect } from './nodes/hexagon.rect';
import { pentagram } from './nodes/pentagram';
import { pentagramAnchors } from './nodes/pentagram.anchor';
import { pentagramIconRect, pentagramTextRect } from './nodes/pentagram.rect';
import { cloud } from './nodes/cloud';
import { cloudAnchors } from './nodes/cloud.anchor';
import { cloudIconRect, cloudTextRect } from './nodes/cloud.rect';
import { message } from './nodes/message';
import { messageIconRect, messageTextRect } from './nodes/message.rect';
import { messageAnchors } from './nodes/message.anchor';
import { file } from './nodes/file';
import { imageIconRect, imageTextRect } from './nodes/image.rect';
import { imageAnchors } from './nodes/image.anchor';
import { cube } from './nodes/cube';
import { cubeAnchors } from './nodes/cube.anchor';
import { cubeIconRect, cubeTextRect } from './nodes/cube.rect';
import { people } from './nodes/people';
import { peopleIconRect, peopleTextRect } from './nodes/people.rect';
import { rectangleIconRect, rectangleTextRect } from './nodes/rectangle.rect';
import { graffiti } from './nodes/graffiti';
import { graffitiAnchors } from './nodes/graffiti.anchor';
import { mindNodeAnchors } from './nodes/mindNode.anchor';
import { mindLine } from './nodes/mindLine';
import { mindLineAnchors } from './nodes/mindLine.anchor';
import { lines } from './nodes/lines';
import { rectangle } from './nodes/rectangle'
import { circle } from './nodes/circle'
import { triangle } from './nodes/triangle'
import { diamond } from './nodes/diamond'
import { leftArrow, rightArrow, twowayArrow } from './nodes/arrow'
import { text } from './nodes/text'
import { line as nodeLine } from './nodes/line'
import { triangleAnchors } from './nodes/triangle.anchor'
import { arrowAnchors } from './nodes/arrow.anchor'
import { lineAnchors } from './nodes/line.anchor'
import { circleIconRect, circleTextRect } from './nodes/circle.rect'
import { triangleIconRect, triangleTextRect } from './nodes/triangle.rect'
import { diamondIconRect, diamondTextRect } from './nodes/diamond.rect'
import { twowayArrowIconRect, twowayArrowTextRect, leftArrowIconRect, leftArrowTextRect, rightArrowIconRect, rightArrowTextRect } from './nodes/arrow.rect'
import { lineIconRect, lineTextRect } from './nodes/line.rect'
import { line, lineControlPoints, calcLineControlPoints } from './lines/line'
import { polyline, polylineControlPoints, pointInPolyline, calcPolylineControlPoints, dockPolylineControlPoint } from './lines/polyline'
import { curve, curveControlPoints, pointInCurve, calcCurveControlPoints } from './lines/curve'
import { calcMindControlPoints } from './lines/mind'
import { triangleSolid, triangle as arrowTriangle } from './arrows/triangle'
import { diamondSolid, diamond as arrowDiamond } from './arrows/diamond'
import { circleSolid, circle as arrowCircle } from './arrows/circle'
import { circleAnchors } from './nodes/circle.anchor'
import { lineUp, lineDown, line as arrowLine } from './arrows/line'
import { pentagon } from './nodes/pentagon'
import { pentagonIconRect, pentagonTextRect } from './nodes/pentagon.rect'
import { pentagonAnchors } from './nodes/pentagon.anchor'
import { hexagon } from './nodes/hexagon'
import { hexagonAnchors } from './nodes/hexagon.anchor'
import { hexagonIconRect, hexagonTextRect } from './nodes/hexagon.rect'
import { pentagram } from './nodes/pentagram'
import { pentagramAnchors } from './nodes/pentagram.anchor'
import { pentagramIconRect, pentagramTextRect } from './nodes/pentagram.rect'
import { cloud } from './nodes/cloud'
import { cloudAnchors } from './nodes/cloud.anchor'
import { cloudIconRect, cloudTextRect } from './nodes/cloud.rect'
import { message } from './nodes/message'
import { messageIconRect, messageTextRect } from './nodes/message.rect'
import { messageAnchors } from './nodes/message.anchor'
import { file } from './nodes/file'
import { imageIconRect, imageTextRect } from './nodes/image.rect'
import { imageAnchors } from './nodes/image.anchor'
import { cube } from './nodes/cube'
import { cubeAnchors } from './nodes/cube.anchor'
import { cubeIconRect, cubeTextRect } from './nodes/cube.rect'
import { people } from './nodes/people'
import { peopleIconRect, peopleTextRect } from './nodes/people.rect'
import { rectangleIconRect, rectangleTextRect } from './nodes/rectangle.rect'
import { graffiti } from './nodes/graffiti'
import { graffitiAnchors } from './nodes/graffiti.anchor'
import { mindNodeAnchors } from './nodes/mindNode.anchor'
import { mindLine } from './nodes/mindLine'
import { mindLineAnchors } from './nodes/mindLine.anchor'
import { lines } from './nodes/lines'
// Functions of drawing a node.
export var drawNodeFns = {};
export var drawNodeFns = {}
// Calc the occupy rect of icon.
export var iconRectFns = {};
export var iconRectFns = {}
// Calc the occupy rect of text.
export var textRectFns = {};
export var textRectFns = {}
// Calc the anchors of node.
export var anchorsFns = {};
export var anchorsFns = {}
// Functions of drawing a line.
export var drawLineFns = {};
export var drawLineFns = {}
// Functions of drawing a arrow.
export var drawArrowFns = {};
function init() {
// ********Default nodes.*******
// Combine
drawNodeFns.combine = rectangle;
// Div
drawNodeFns.div = rectangle;
// graffiti
drawNodeFns.graffiti = graffiti;
anchorsFns.graffiti = graffitiAnchors;
// lines
drawNodeFns.lines = lines;
// Square
drawNodeFns.square = rectangle;
// Rectangle
drawNodeFns.rectangle = rectangle;
iconRectFns.rectangle = rectangleIconRect;
textRectFns.rectangle = rectangleTextRect;
// Ciricle
drawNodeFns.circle = circle;
iconRectFns.circle = circleIconRect;
textRectFns.circle = circleTextRect;
anchorsFns.circle = circleAnchors;
// Triangle
drawNodeFns.triangle = triangle;
anchorsFns.triangle = triangleAnchors;
iconRectFns.triangle = triangleIconRect;
textRectFns.triangle = triangleTextRect;
// Diamond
drawNodeFns.diamond = diamond;
iconRectFns.diamond = diamondIconRect;
textRectFns.diamond = diamondTextRect;
// Hexagon
drawNodeFns.hexagon = hexagon;
iconRectFns.hexagon = hexagonIconRect;
textRectFns.hexagon = hexagonTextRect;
anchorsFns.hexagon = hexagonAnchors;
// Pentagon
drawNodeFns.pentagon = pentagon;
iconRectFns.pentagon = pentagonIconRect;
textRectFns.pentagon = pentagonTextRect;
anchorsFns.pentagon = pentagonAnchors;
// Pentagram
drawNodeFns.pentagram = pentagram;
iconRectFns.pentagram = pentagramIconRect;
textRectFns.pentagram = pentagramTextRect;
anchorsFns.pentagram = pentagramAnchors;
// Left arrow
drawNodeFns.leftArrow = leftArrow;
anchorsFns.leftArrow = arrowAnchors;
iconRectFns.leftArrow = leftArrowIconRect;
textRectFns.leftArrow = leftArrowTextRect;
// Right arrow
drawNodeFns.rightArrow = rightArrow;
anchorsFns.rightArrow = arrowAnchors;
iconRectFns.rightArrow = rightArrowIconRect;
textRectFns.rightArrow = rightArrowTextRect;
// Two-way arrow
drawNodeFns.twowayArrow = twowayArrow;
anchorsFns.twowayArrow = arrowAnchors;
iconRectFns.twowayArrow = twowayArrowIconRect;
textRectFns.twowayArrow = twowayArrowTextRect;
// Cloud
drawNodeFns.cloud = cloud;
anchorsFns.cloud = cloudAnchors;
iconRectFns.cloud = cloudIconRect;
textRectFns.cloud = cloudTextRect;
// Message
drawNodeFns.message = message;
anchorsFns.message = messageAnchors;
iconRectFns.message = messageIconRect;
textRectFns.message = messageTextRect;
// File
drawNodeFns.file = file;
// Text
drawNodeFns.text = text;
iconRectFns.text = lineIconRect;
// Line
drawNodeFns.line = nodeLine;
anchorsFns.line = lineAnchors;
iconRectFns.line = lineIconRect;
textRectFns.line = lineTextRect;
// Image
drawNodeFns.image = function (ctx, node) { };
iconRectFns.image = imageIconRect;
textRectFns.image = imageTextRect;
anchorsFns.image = imageAnchors;
// Cube
drawNodeFns.cube = cube;
anchorsFns.cube = cubeAnchors;
iconRectFns.cube = cubeIconRect;
textRectFns.cube = cubeTextRect;
// People
drawNodeFns.people = people;
iconRectFns.people = peopleIconRect;
textRectFns.people = peopleTextRect;
// MindNode
drawNodeFns.mindNode = rectangle;
anchorsFns.mindNode = mindNodeAnchors;
iconRectFns.mindNode = rectangleIconRect;
textRectFns.mindNode = rectangleTextRect;
// MindLine
drawNodeFns.mindLine = mindLine;
anchorsFns.mindLine = mindLineAnchors;
// ********end********
// ********Default lines.*******
drawLineFns.line = {
drawFn: line,
drawControlPointsFn: lineControlPoints,
controlPointsFn: calcLineControlPoints,
pointIn: pointInPolyline,
};
drawLineFns.polyline = {
drawFn: polyline,
drawControlPointsFn: polylineControlPoints,
controlPointsFn: calcPolylineControlPoints,
dockControlPointFn: dockPolylineControlPoint,
pointIn: pointInPolyline,
};
drawLineFns.curve = {
drawFn: curve,
drawControlPointsFn: curveControlPoints,
controlPointsFn: calcCurveControlPoints,
pointIn: pointInCurve,
};
drawLineFns.mind = {
drawFn: curve,
drawControlPointsFn: curveControlPoints,
controlPointsFn: calcMindControlPoints,
pointIn: pointInCurve,
};
// ********end********
// ********Default nodes.*******
drawArrowFns.triangleSolid = triangleSolid;
drawArrowFns.triangle = arrowTriangle;
drawArrowFns.diamondSolid = diamondSolid;
drawArrowFns.diamond = arrowDiamond;
drawArrowFns.circleSolid = circleSolid;
drawArrowFns.circle = arrowCircle;
drawArrowFns.line = arrowLine;
drawArrowFns.lineUp = lineUp;
drawArrowFns.lineDown = lineDown;
// ********end********
export var drawArrowFns = {}
function init () {
// ********Default nodes.*******
// Combine
drawNodeFns.combine = rectangle
// Div
drawNodeFns.div = rectangle
// graffiti
drawNodeFns.graffiti = graffiti
anchorsFns.graffiti = graffitiAnchors
// lines
drawNodeFns.lines = lines
// Square
drawNodeFns.square = rectangle
// Rectangle
drawNodeFns.rectangle = rectangle
iconRectFns.rectangle = rectangleIconRect
textRectFns.rectangle = rectangleTextRect
// Ciricle
drawNodeFns.circle = circle
iconRectFns.circle = circleIconRect
textRectFns.circle = circleTextRect
anchorsFns.circle = circleAnchors
// Triangle
drawNodeFns.triangle = triangle
anchorsFns.triangle = triangleAnchors
iconRectFns.triangle = triangleIconRect
textRectFns.triangle = triangleTextRect
// Diamond
drawNodeFns.diamond = diamond
iconRectFns.diamond = diamondIconRect
textRectFns.diamond = diamondTextRect
// Hexagon
drawNodeFns.hexagon = hexagon
iconRectFns.hexagon = hexagonIconRect
textRectFns.hexagon = hexagonTextRect
anchorsFns.hexagon = hexagonAnchors
// Pentagon
drawNodeFns.pentagon = pentagon
iconRectFns.pentagon = pentagonIconRect
textRectFns.pentagon = pentagonTextRect
anchorsFns.pentagon = pentagonAnchors
// Pentagram
drawNodeFns.pentagram = pentagram
iconRectFns.pentagram = pentagramIconRect
textRectFns.pentagram = pentagramTextRect
anchorsFns.pentagram = pentagramAnchors
// Left arrow
drawNodeFns.leftArrow = leftArrow
anchorsFns.leftArrow = arrowAnchors
iconRectFns.leftArrow = leftArrowIconRect
textRectFns.leftArrow = leftArrowTextRect
// Right arrow
drawNodeFns.rightArrow = rightArrow
anchorsFns.rightArrow = arrowAnchors
iconRectFns.rightArrow = rightArrowIconRect
textRectFns.rightArrow = rightArrowTextRect
// Two-way arrow
drawNodeFns.twowayArrow = twowayArrow
anchorsFns.twowayArrow = arrowAnchors
iconRectFns.twowayArrow = twowayArrowIconRect
textRectFns.twowayArrow = twowayArrowTextRect
// Cloud
drawNodeFns.cloud = cloud
anchorsFns.cloud = cloudAnchors
iconRectFns.cloud = cloudIconRect
textRectFns.cloud = cloudTextRect
// Message
drawNodeFns.message = message
anchorsFns.message = messageAnchors
iconRectFns.message = messageIconRect
textRectFns.message = messageTextRect
// File
drawNodeFns.file = file
// Text
drawNodeFns.text = text
iconRectFns.text = lineIconRect
// Line
drawNodeFns.line = nodeLine
anchorsFns.line = lineAnchors
iconRectFns.line = lineIconRect
textRectFns.line = lineTextRect
// Image
drawNodeFns.image = function (ctx, node) { }
iconRectFns.image = imageIconRect
textRectFns.image = imageTextRect
anchorsFns.image = imageAnchors
// Cube
drawNodeFns.cube = cube
anchorsFns.cube = cubeAnchors
iconRectFns.cube = cubeIconRect
textRectFns.cube = cubeTextRect
// People
drawNodeFns.people = people
iconRectFns.people = peopleIconRect
textRectFns.people = peopleTextRect
// MindNode
drawNodeFns.mindNode = rectangle
anchorsFns.mindNode = mindNodeAnchors
iconRectFns.mindNode = rectangleIconRect
textRectFns.mindNode = rectangleTextRect
// MindLine
drawNodeFns.mindLine = mindLine
anchorsFns.mindLine = mindLineAnchors
// ********end********
// ********Default lines.*******
drawLineFns.line = {
drawFn: line,
drawControlPointsFn: lineControlPoints,
controlPointsFn: calcLineControlPoints,
pointIn: pointInPolyline
}
drawLineFns.polyline = {
drawFn: polyline,
drawControlPointsFn: polylineControlPoints,
controlPointsFn: calcPolylineControlPoints,
dockControlPointFn: dockPolylineControlPoint,
pointIn: pointInPolyline
}
drawLineFns.curve = {
drawFn: curve,
drawControlPointsFn: curveControlPoints,
controlPointsFn: calcCurveControlPoints,
pointIn: pointInCurve
}
drawLineFns.mind = {
drawFn: curve,
drawControlPointsFn: curveControlPoints,
controlPointsFn: calcMindControlPoints,
pointIn: pointInCurve
}
// ********end********
// ********Default nodes.*******
drawArrowFns.triangleSolid = triangleSolid
drawArrowFns.triangle = arrowTriangle
drawArrowFns.diamondSolid = diamondSolid
drawArrowFns.diamond = arrowDiamond
drawArrowFns.circleSolid = circleSolid
drawArrowFns.circle = arrowCircle
drawArrowFns.line = arrowLine
drawArrowFns.lineUp = lineUp
drawArrowFns.lineDown = lineDown
// ********end********
}
init();
init()
// registerNode: Register a custom node.
// name - The name of node.
// drawFn - How to draw.
@@ -215,16 +215,16 @@ init();
// iconRectFn - How to get the icon rect.
// textRectFn - How to get the text rect.
// protect - No overwirte the node if exists.
export function registerNode(name, drawFn, anchorsFn, iconRectFn, textRectFn, protect) {
// Exist
if (drawNodeFns[name] && protect) {
return false;
}
drawNodeFns[name] = drawFn;
anchorsFns[name] = anchorsFn;
iconRectFns[name] = iconRectFn;
textRectFns[name] = textRectFn;
return true;
export function registerNode (name, drawFn, anchorsFn, iconRectFn, textRectFn, protect) {
// Exist
if (drawNodeFns[name] && protect) {
return false
}
drawNodeFns[name] = drawFn
anchorsFns[name] = anchorsFn
iconRectFns[name] = iconRectFn
textRectFns[name] = textRectFn
return true
}
// registerLine: Register a custom line.
// name - The name of line.
@@ -233,36 +233,36 @@ export function registerNode(name, drawFn, anchorsFn, iconRectFn, textRectFn, pr
// controlPointsFn - How to get the controlPoints.
// dockControlPointFn - Dock a point to horizontal/vertial or related position.
// force - Overwirte the node if exists.
export function registerLine(name, drawFn, drawControlPointsFn, controlPointsFn, dockControlPointFn, pointInFn, getLength, getCenter, getPointByPos, force) {
if (force === void 0) { force = true; }
// Exist
if (drawLineFns[name] && !force) {
return false;
}
drawLineFns[name] = {
drawFn: drawFn,
drawControlPointsFn: drawControlPointsFn,
controlPointsFn: controlPointsFn,
dockControlPointFn: dockControlPointFn,
pointIn: pointInFn,
getLength: getLength,
getCenter: getCenter,
getPointByPos: getPointByPos,
};
return true;
export function registerLine (name, drawFn, drawControlPointsFn, controlPointsFn, dockControlPointFn, pointInFn, getLength, getCenter, getPointByPos, force) {
if (force === void 0) { force = true }
// Exist
if (drawLineFns[name] && !force) {
return false
}
drawLineFns[name] = {
drawFn: drawFn,
drawControlPointsFn: drawControlPointsFn,
controlPointsFn: controlPointsFn,
dockControlPointFn: dockControlPointFn,
pointIn: pointInFn,
getLength: getLength,
getCenter: getCenter,
getPointByPos: getPointByPos
}
return true
}
// registerArrow: Register a custom arrow.
// name - the name of arrow.
// drawFn - how to draw.
// force - Overwirte the node if exists.
export function registerArrow(name, drawFn, protect) {
// Exist
if (drawArrowFns[name] && protect) {
return false;
}
drawArrowFns[name] = drawFn;
return true;
export function registerArrow (name, drawFn, protect) {
// Exist
if (drawArrowFns[name] && protect) {
return false
}
drawArrowFns[name] = drawFn
return true
}
window.registerTopologyNode = registerNode;
window.registerTopologyLine = registerLine;
//# sourceMappingURL=default.js.map
window.registerTopologyNode = registerNode
window.registerTopologyLine = registerLine
// # sourceMappingURL=default.js.map

View File

@@ -1,19 +1,17 @@
import { Rect } from '../models/rect';
export function defaultIconRect(node) {
if (node.image && node.imageWidth) {
node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.imageWidth, node.imageHeight);
}
else if (node.icon && node.iconSize) {
node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.iconSize, node.iconSize);
}
else {
node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, (node.rect.height * 3) / 4 - node.paddingTopNum - node.paddingBottomNum);
}
node.fullIconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum);
import { Rect } from '../models/rect'
export function defaultIconRect (node) {
if (node.image && node.imageWidth) {
node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.imageWidth, node.imageHeight)
} else if (node.icon && node.iconSize) {
node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.iconSize, node.iconSize)
} else {
node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, (node.rect.height * 3) / 4 - node.paddingTopNum - node.paddingBottomNum)
}
node.fullIconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum)
}
export function defaultTextRect(node) {
var height = node.rect.height - node.paddingTopNum - node.paddingBottomNum;
node.textRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum + (height * 3) / 4, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height / 4);
node.fullTextRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height);
export function defaultTextRect (node) {
const height = node.rect.height - node.paddingTopNum - node.paddingBottomNum
node.textRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum + (height * 3) / 4, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height / 4)
node.fullTextRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height)
}
//# sourceMappingURL=default.rect.js.map
// # sourceMappingURL=default.rect.js.map

View File

@@ -1,4 +1,4 @@
export * from './default';
export * from './nodes/rectangle';
export * from './nodes/text';
//# sourceMappingURL=index.js.map
export * from './default'
export * from './nodes/rectangle'
export * from './nodes/text'
// # sourceMappingURL=index.js.map

View File

@@ -1,130 +1,128 @@
import { Store } from 'le5le-store';
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
import { pointInLine } from '../../utils/canvas';
import { rgba } from '../../utils/math';
var distance = 80;
export function curve(ctx, l) {
ctx.beginPath();
ctx.moveTo(l.from.x, l.from.y);
ctx.bezierCurveTo(l.controlPoints[0].x, l.controlPoints[0].y, l.controlPoints[1].x, l.controlPoints[1].y, l.to.x, l.to.y);
ctx.stroke();
import { Store } from 'le5le-store'
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
import { pointInLine } from '../../utils/canvas'
import { rgba } from '../../utils/math'
const distance = 80
export function curve (ctx, l) {
ctx.beginPath()
ctx.moveTo(l.from.x, l.from.y)
ctx.bezierCurveTo(l.controlPoints[0].x, l.controlPoints[0].y, l.controlPoints[1].x, l.controlPoints[1].y, l.to.x, l.to.y)
ctx.stroke()
}
export function curveControlPoints(ctx, l) {
ctx.save();
ctx.fillStyle = rgba(0.5, ctx.strokeStyle + '');
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(l.from.x, l.from.y);
ctx.lineTo(l.controlPoints[0].x, l.controlPoints[0].y);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(l.to.x, l.to.y);
ctx.lineTo(l.controlPoints[1].x, l.controlPoints[1].y);
ctx.stroke();
ctx.fillStyle = '#fff';
ctx.lineWidth = 2;
for (var _i = 0, _a = l.controlPoints; _i < _a.length; _i++) {
var item = _a[_i];
ctx.beginPath();
ctx.arc(item.x, item.y, 4, 0, Math.PI * 2);
ctx.stroke();
ctx.fill();
}
ctx.restore();
export function curveControlPoints (ctx, l) {
ctx.save()
ctx.fillStyle = rgba(0.5, ctx.strokeStyle + '')
ctx.lineWidth = 1
ctx.beginPath()
ctx.moveTo(l.from.x, l.from.y)
ctx.lineTo(l.controlPoints[0].x, l.controlPoints[0].y)
ctx.stroke()
ctx.beginPath()
ctx.moveTo(l.to.x, l.to.y)
ctx.lineTo(l.controlPoints[1].x, l.controlPoints[1].y)
ctx.stroke()
ctx.fillStyle = '#fff'
ctx.lineWidth = 2
for (let _i = 0, _a = l.controlPoints; _i < _a.length; _i++) {
const item = _a[_i]
ctx.beginPath()
ctx.arc(item.x, item.y, 4, 0, Math.PI * 2)
ctx.stroke()
ctx.fill()
}
ctx.restore()
}
export function calcCurveControlPoints(l) {
if (!l.from.direction) {
l.from.direction = Direction.Bottom;
}
export function calcCurveControlPoints (l) {
if (!l.from.direction) {
l.from.direction = Direction.Bottom
}
if (!l.to.direction) {
l.to.direction = (l.from.direction + 2) % 4
if (!l.to.direction) {
l.to.direction = (l.from.direction + 2) % 4;
if (!l.to.direction) {
l.to.direction = Direction.Left;
}
l.to.direction = Direction.Left
}
l.controlPoints = [getControlPt(l.from, l.to), getControlPt(l.to, l.from)];
Store.set(generateStoreKey(l, 'pts-') + l.id, undefined);
}
l.controlPoints = [getControlPt(l.from, l.to), getControlPt(l.to, l.from)]
Store.set(generateStoreKey(l, 'pts-') + l.id, undefined)
}
export function pointInCurve(point, l) {
var points = Store.get(generateStoreKey(l, 'pts-') + l.id);
if (!points) {
points = [l.from];
if (l.controlPoints) {
for (var i = 0.01; i < 1; i += 0.01) {
points.push(getBezierPoint(i, l.from, l.controlPoints[0], l.controlPoints[1], l.to));
}
}
points.push(l.to);
Store.set(generateStoreKey(l, 'pts-') + l.id, points);
export function pointInCurve (point, l) {
let points = Store.get(generateStoreKey(l, 'pts-') + l.id)
if (!points) {
points = [l.from]
if (l.controlPoints) {
for (var i = 0.01; i < 1; i += 0.01) {
points.push(getBezierPoint(i, l.from, l.controlPoints[0], l.controlPoints[1], l.to))
}
}
var cnt = points.length - 1;
for (var i = 0; i < cnt; ++i) {
if (pointInLine(point, points[i], points[i + 1])) {
return true;
}
points.push(l.to)
Store.set(generateStoreKey(l, 'pts-') + l.id, points)
}
const cnt = points.length - 1
for (var i = 0; i < cnt; ++i) {
if (pointInLine(point, points[i], points[i + 1])) {
return true
}
return false;
}
return false
}
// Get a point in bezier.
// pos - The position of point in bezier. It is expressed as a percentage(0 - 1).
export function getBezierPoint(pos, from, cp1, cp2, to) {
var x1 = from.x, y1 = from.y;
var x2 = to.x, y2 = to.y;
var cx1 = cp1.x, cy1 = cp1.y;
var cx2 = cp2.x, cy2 = cp2.y;
var x = x1 * (1 - pos) * (1 - pos) * (1 - pos) +
export function getBezierPoint (pos, from, cp1, cp2, to) {
const x1 = from.x; const y1 = from.y
const x2 = to.x; const y2 = to.y
const cx1 = cp1.x; const cy1 = cp1.y
const cx2 = cp2.x; const cy2 = cp2.y
const x = x1 * (1 - pos) * (1 - pos) * (1 - pos) +
3 * cx1 * pos * (1 - pos) * (1 - pos) +
3 * cx2 * pos * pos * (1 - pos) +
x2 * pos * pos * pos;
var y = y1 * (1 - pos) * (1 - pos) * (1 - pos) +
x2 * pos * pos * pos
const y = y1 * (1 - pos) * (1 - pos) * (1 - pos) +
3 * cy1 * pos * (1 - pos) * (1 - pos) +
3 * cy2 * pos * pos * (1 - pos) +
y2 * pos * pos * pos;
return new Point(x, y);
y2 * pos * pos * pos
return new Point(x, y)
}
export function getControlPt(pt, to) {
var point = new Point(pt.x, pt.y, pt.direction, pt.anchorIndex, pt.id);
var dis = window.topologyControlPtDistance || distance;
if ((pt.direction === Direction.Up || pt.direction === Direction.Bottom) && Math.abs(pt.x - to.x) < 3) {
if (to.y > pt.y) {
dis = Math.round((to.y - pt.y) / 3);
point.y += dis;
}
else {
dis = Math.round((pt.y - to.y) / 3);
point.y -= dis;
}
return point;
export function getControlPt (pt, to) {
const point = new Point(pt.x, pt.y, pt.direction, pt.anchorIndex, pt.id)
let dis = window.topologyControlPtDistance || distance
if ((pt.direction === Direction.Up || pt.direction === Direction.Bottom) && Math.abs(pt.x - to.x) < 3) {
if (to.y > pt.y) {
dis = Math.round((to.y - pt.y) / 3)
point.y += dis
} else {
dis = Math.round((pt.y - to.y) / 3)
point.y -= dis
}
if ((pt.direction === Direction.Left || pt.direction === Direction.Right) && Math.abs(pt.y - to.y) < 3) {
if (to.x > pt.x) {
dis = Math.round((to.x - pt.x) / 3);
point.x += dis;
}
else {
dis = Math.round((pt.x - to.x) / 3);
point.x -= dis;
}
return point;
return point
}
if ((pt.direction === Direction.Left || pt.direction === Direction.Right) && Math.abs(pt.y - to.y) < 3) {
if (to.x > pt.x) {
dis = Math.round((to.x - pt.x) / 3)
point.x += dis
} else {
dis = Math.round((pt.x - to.x) / 3)
point.x -= dis
}
switch (pt.direction) {
case Direction.Up:
point.y -= dis;
break;
case Direction.Right:
point.x += dis;
break;
case Direction.Bottom:
point.y += dis;
break;
case Direction.Left:
point.x -= dis;
break;
}
return point;
return point
}
switch (pt.direction) {
case Direction.Up:
point.y -= dis
break
case Direction.Right:
point.x += dis
break
case Direction.Bottom:
point.y += dis
break
case Direction.Left:
point.x -= dis
break
}
return point
}
export function generateStoreKey(pen, key) {
return pen.getTID() + "-" + key;
export function generateStoreKey (pen, key) {
return pen.getTID() + '-' + key
}
//# sourceMappingURL=curve.js.map
// # sourceMappingURL=curve.js.map

View File

@@ -1,11 +1,11 @@
export function line(ctx, l) {
ctx.beginPath();
ctx.moveTo(l.from.x, l.from.y);
ctx.lineTo(l.to.x, l.to.y);
ctx.stroke();
export function line (ctx, l) {
ctx.beginPath()
ctx.moveTo(l.from.x, l.from.y)
ctx.lineTo(l.to.x, l.to.y)
ctx.stroke()
}
export function lineControlPoints(ctx, l) { }
export function calcLineControlPoints(l) {
l.controlPoints = [];
export function lineControlPoints (ctx, l) { }
export function calcLineControlPoints (l) {
l.controlPoints = []
}
//# sourceMappingURL=line.js.map
// # sourceMappingURL=line.js.map

View File

@@ -1,32 +1,32 @@
import { Store } from 'le5le-store';
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
import { generateStoreKey } from './curve';
var distance = 20;
export function calcMindControlPoints(l) {
if (!l.from.direction) {
l.from.direction = Direction.Bottom;
}
import { Store } from 'le5le-store'
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
import { generateStoreKey } from './curve'
const distance = 20
export function calcMindControlPoints (l) {
if (!l.from.direction) {
l.from.direction = Direction.Bottom
}
if (!l.to.direction) {
l.to.direction = (l.from.direction + 2) % 4
if (!l.to.direction) {
l.to.direction = (l.from.direction + 2) % 4;
if (!l.to.direction) {
l.to.direction = Direction.Left;
}
l.to.direction = Direction.Left
}
switch (l.from.direction) {
case Direction.Up:
l.controlPoints = [new Point(l.from.x, l.from.y - distance), new Point(l.from.x, l.to.y)];
break;
case Direction.Right:
l.controlPoints = [new Point(l.from.x + distance, l.from.y), new Point(l.from.x, l.to.y)];
break;
case Direction.Bottom:
l.controlPoints = [new Point(l.from.x, l.from.y + distance), new Point(l.from.x, l.to.y)];
break;
case Direction.Left:
l.controlPoints = [new Point(l.from.x - distance, l.from.y), new Point(l.from.x, l.to.y)];
break;
}
Store.set(generateStoreKey(l, 'pts-') + l.id, undefined);
}
switch (l.from.direction) {
case Direction.Up:
l.controlPoints = [new Point(l.from.x, l.from.y - distance), new Point(l.from.x, l.to.y)]
break
case Direction.Right:
l.controlPoints = [new Point(l.from.x + distance, l.from.y), new Point(l.from.x, l.to.y)]
break
case Direction.Bottom:
l.controlPoints = [new Point(l.from.x, l.from.y + distance), new Point(l.from.x, l.to.y)]
break
case Direction.Left:
l.controlPoints = [new Point(l.from.x - distance, l.from.y), new Point(l.from.x, l.to.y)]
break
}
Store.set(generateStoreKey(l, 'pts-') + l.id, undefined)
}
//# sourceMappingURL=mind.js.map
// # sourceMappingURL=mind.js.map

View File

@@ -1,309 +1,285 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
import { pointInLine } from '../../utils/canvas';
var minDistance = 50;
export function polyline(ctx, l) {
ctx.beginPath();
ctx.moveTo(l.from.x, l.from.y);
for (var _i = 0, _a = l.controlPoints; _i < _a.length; _i++) {
var item = _a[_i];
ctx.lineTo(item.x, item.y);
}
ctx.lineTo(l.to.x, l.to.y);
ctx.stroke();
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
import { pointInLine } from '../../utils/canvas'
const minDistance = 50
export function polyline (ctx, l) {
ctx.beginPath()
ctx.moveTo(l.from.x, l.from.y)
for (let _i = 0, _a = l.controlPoints; _i < _a.length; _i++) {
const item = _a[_i]
ctx.lineTo(item.x, item.y)
}
ctx.lineTo(l.to.x, l.to.y)
ctx.stroke()
}
export function polylineControlPoints(ctx, l) {
ctx.save();
ctx.fillStyle = '#fff';
ctx.lineWidth = 2;
for (var _i = 0, _a = l.controlPoints; _i < _a.length; _i++) {
var item = _a[_i];
ctx.beginPath();
ctx.arc(item.x, item.y, 4, 0, Math.PI * 2);
ctx.stroke();
ctx.fill();
}
ctx.restore();
export function polylineControlPoints (ctx, l) {
ctx.save()
ctx.fillStyle = '#fff'
ctx.lineWidth = 2
for (let _i = 0, _a = l.controlPoints; _i < _a.length; _i++) {
const item = _a[_i]
ctx.beginPath()
ctx.arc(item.x, item.y, 4, 0, Math.PI * 2)
ctx.stroke()
ctx.fill()
}
ctx.restore()
}
export function calcPolylineControlPoints(l) {
l.controlPoints = [];
var from = getDirectionPoint(l.from, l.to);
if (l.from.direction) {
l.controlPoints.push(from);
}
var to = getDirectionPoint(l.to, l.from);
var pts;
switch (from.direction) {
case Direction.Up:
pts = getNextPointByUp(from, to);
break;
case Direction.Right:
pts = getNextPointByRight(from, to);
break;
case Direction.Bottom:
pts = getNextPointByBottom(from, to);
break;
case Direction.Left:
pts = getNextPointByLeft(from, to);
break;
}
l.controlPoints.push.apply(l.controlPoints, pts);
if (l.to.direction) {
l.controlPoints.push(to);
}
export function calcPolylineControlPoints (l) {
l.controlPoints = []
const from = getDirectionPoint(l.from, l.to)
if (l.from.direction) {
l.controlPoints.push(from)
}
const to = getDirectionPoint(l.to, l.from)
let pts
switch (from.direction) {
case Direction.Up:
pts = getNextPointByUp(from, to)
break
case Direction.Right:
pts = getNextPointByRight(from, to)
break
case Direction.Bottom:
pts = getNextPointByBottom(from, to)
break
case Direction.Left:
pts = getNextPointByLeft(from, to)
break
}
l.controlPoints.push.apply(l.controlPoints, pts)
if (l.to.direction) {
l.controlPoints.push(to)
}
}
export function pointInPolyline(point, l) {
if (!l.controlPoints || !l.controlPoints.length) {
return pointInLine(point, l.from, l.to, l.lineWidth / 2);
export function pointInPolyline (point, l) {
if (!l.controlPoints || !l.controlPoints.length) {
return pointInLine(point, l.from, l.to, l.lineWidth / 2)
}
if (pointInLine(point, l.from, l.controlPoints[0])) {
return true
}
if (pointInLine(point, l.to, l.controlPoints[l.controlPoints.length - 1])) {
return true
}
for (let i = 0; i < l.controlPoints.length - 1; ++i) {
if (pointInLine(point, l.controlPoints[i], l.controlPoints[i + 1])) {
return true
}
if (pointInLine(point, l.from, l.controlPoints[0])) {
return true;
}
if (pointInLine(point, l.to, l.controlPoints[l.controlPoints.length - 1])) {
return true;
}
for (var i = 0; i < l.controlPoints.length - 1; ++i) {
if (pointInLine(point, l.controlPoints[i], l.controlPoints[i + 1])) {
return true;
}
}
return false;
}
return false
}
export function dockPolylineControlPoint(point, l) {
var pts = [l.from];
pts.push.apply(pts, l.controlPoints);
pts.push(l.to);
for (var _i = 0, pts_1 = pts; _i < pts_1.length; _i++) {
var item = pts_1[_i];
if (Math.abs(point.x - item.x) < 7) {
point.x = item.x;
}
if (Math.abs(point.y - item.y) < 7) {
point.y = item.y;
}
export function dockPolylineControlPoint (point, l) {
const pts = [l.from]
pts.push.apply(pts, l.controlPoints)
pts.push(l.to)
for (let _i = 0, pts_1 = pts; _i < pts_1.length; _i++) {
const item = pts_1[_i]
if (Math.abs(point.x - item.x) < 7) {
point.x = item.x
}
if (Math.abs(point.y - item.y) < 7) {
point.y = item.y
}
}
}
function getDirectionPoint(pt, to) {
var point = pt.clone();
switch (pt.direction) {
case Direction.Up:
if (to.y < pt.y) {
point.y -= Math.round((pt.y - to.y) / 2);
}
else {
point.y -= minDistance;
}
break;
case Direction.Right:
if (to.x > pt.x) {
point.x += Math.round((to.x - pt.x) / 2);
}
else {
point.x += minDistance;
}
break;
case Direction.Bottom:
if (to.y > pt.y) {
point.y += Math.round((to.y - pt.y) / 2);
}
else {
point.y += minDistance;
}
break;
case Direction.Left:
if (to.x < pt.x) {
point.x -= Math.round((pt.x - to.x) / 2);
}
else {
point.x -= minDistance;
}
break;
}
return point;
function getDirectionPoint (pt, to) {
const point = pt.clone()
switch (pt.direction) {
case Direction.Up:
if (to.y < pt.y) {
point.y -= Math.round((pt.y - to.y) / 2)
} else {
point.y -= minDistance
}
break
case Direction.Right:
if (to.x > pt.x) {
point.x += Math.round((to.x - pt.x) / 2)
} else {
point.x += minDistance
}
break
case Direction.Bottom:
if (to.y > pt.y) {
point.y += Math.round((to.y - pt.y) / 2)
} else {
point.y += minDistance
}
break
case Direction.Left:
if (to.x < pt.x) {
point.x -= Math.round((pt.x - to.x) / 2)
} else {
point.x -= minDistance
}
break
}
return point
}
function getNextPointByUp(from, to) {
if (from.x === to.x || from.y === to.y) {
return [];
}
// The to point above the from point.
if (from.y > to.y) {
if (to.direction === Direction.Up && from.y - to.y > 3 * minDistance) {
if (from.x < to.x) {
if (to.x - from.x < minDistance) {
return [new Point(from.x - 2 * minDistance, from.y), new Point(from.x - 2 * minDistance, to.y)];
}
return [new Point(from.x, to.y)];
}
else {
if (from.x - to.x < minDistance) {
return [new Point(from.x + 2 * minDistance, from.y), new Point(from.x + 2 * minDistance, to.y)];
}
return [new Point(from.x, to.y)];
}
function getNextPointByUp (from, to) {
if (from.x === to.x || from.y === to.y) {
return []
}
// The to point above the from point.
if (from.y > to.y) {
if (to.direction === Direction.Up && from.y - to.y > 3 * minDistance) {
if (from.x < to.x) {
if (to.x - from.x < minDistance) {
return [new Point(from.x - 2 * minDistance, from.y), new Point(from.x - 2 * minDistance, to.y)]
}
else {
// Left top
if ((to.direction === Direction.Left && from.x > to.x) || (to.direction === Direction.Right && from.x < to.x)) {
return [new Point(to.x, from.y)];
}
return [new Point(from.x, to.y)];
return [new Point(from.x, to.y)]
} else {
if (from.x - to.x < minDistance) {
return [new Point(from.x + 2 * minDistance, from.y), new Point(from.x + 2 * minDistance, to.y)]
}
// The to point below the from point.
}
else {
if (to.direction === Direction.Bottom) {
if (from.x < to.x) {
return getHorizontalPoints(from, to);
}
else {
var pts = getHorizontalPoints(to, from);
return [pts[1], pts[0]];
}
}
else {
return [new Point(to.x, from.y)];
}
}
}
function getNextPointByBottom(from, to) {
if (from.x === to.x || from.y === to.y) {
return [];
return [new Point(from.x, to.y)]
}
} else {
// Left top
if ((to.direction === Direction.Left && from.x > to.x) || (to.direction === Direction.Right && from.x < to.x)) {
return [new Point(to.x, from.y)]
}
return [new Point(from.x, to.y)]
}
// The to point below the from point.
if (from.y < to.y) {
if (to.direction === Direction.Bottom && to.y - from.y > 3 * minDistance) {
if (from.x < to.x) {
if (to.x - from.x < minDistance) {
return [new Point(from.x - 2 * minDistance, from.y), new Point(from.x - 2 * minDistance, to.y)];
}
return [new Point(from.x, to.y)];
}
else {
if (from.x - to.x < minDistance) {
return [new Point(from.x + 2 * minDistance, from.y), new Point(from.x + 2 * minDistance, to.y)];
}
return [new Point(from.x, to.y)];
}
}
else {
if ((to.direction === Direction.Left && from.x > to.x) || (to.direction === Direction.Right && from.x < to.x)) {
return [new Point(to.x, from.y)];
}
return [new Point(from.x, to.y)];
}
// The to point below the from point.
}
else {
if (to.direction === Direction.Up) {
if (from.x < to.x) {
return getHorizontalPoints(from, to);
}
else {
var pts = getHorizontalPoints(to, from);
return [pts[1], pts[0]];
}
}
else {
return [new Point(to.x, from.y)];
}
} else {
if (to.direction === Direction.Bottom) {
if (from.x < to.x) {
return getHorizontalPoints(from, to)
} else {
const pts = getHorizontalPoints(to, from)
return [pts[1], pts[0]]
}
} else {
return [new Point(to.x, from.y)]
}
}
}
function getNextPointByLeft(from, to) {
if (from.x === to.x || from.y === to.y) {
return [];
}
// The to point is on the left.
if (from.x > to.x) {
if (to.direction === Direction.Left && from.x - to.x > 3 * minDistance) {
if (from.y < to.y) {
if (to.y - from.y < minDistance) {
return [new Point(from.x, from.y + 2 * minDistance), new Point(to.x, from.y + 2 * minDistance)];
}
return [new Point(to.x, from.y)];
}
else {
if (from.y - to.y < minDistance) {
return [new Point(from.x, from.y - 2 * minDistance), new Point(to.x, from.y - 2 * minDistance)];
}
return [new Point(to.x, from.y)];
}
function getNextPointByBottom (from, to) {
if (from.x === to.x || from.y === to.y) {
return []
}
// The to point below the from point.
if (from.y < to.y) {
if (to.direction === Direction.Bottom && to.y - from.y > 3 * minDistance) {
if (from.x < to.x) {
if (to.x - from.x < minDistance) {
return [new Point(from.x - 2 * minDistance, from.y), new Point(from.x - 2 * minDistance, to.y)]
}
else {
if (to.direction === Direction.Left ||
return [new Point(from.x, to.y)]
} else {
if (from.x - to.x < minDistance) {
return [new Point(from.x + 2 * minDistance, from.y), new Point(from.x + 2 * minDistance, to.y)]
}
return [new Point(from.x, to.y)]
}
} else {
if ((to.direction === Direction.Left && from.x > to.x) || (to.direction === Direction.Right && from.x < to.x)) {
return [new Point(to.x, from.y)]
}
return [new Point(from.x, to.y)]
}
// The to point below the from point.
} else {
if (to.direction === Direction.Up) {
if (from.x < to.x) {
return getHorizontalPoints(from, to)
} else {
const pts = getHorizontalPoints(to, from)
return [pts[1], pts[0]]
}
} else {
return [new Point(to.x, from.y)]
}
}
}
function getNextPointByLeft (from, to) {
if (from.x === to.x || from.y === to.y) {
return []
}
// The to point is on the left.
if (from.x > to.x) {
if (to.direction === Direction.Left && from.x - to.x > 3 * minDistance) {
if (from.y < to.y) {
if (to.y - from.y < minDistance) {
return [new Point(from.x, from.y + 2 * minDistance), new Point(to.x, from.y + 2 * minDistance)]
}
return [new Point(to.x, from.y)]
} else {
if (from.y - to.y < minDistance) {
return [new Point(from.x, from.y - 2 * minDistance), new Point(to.x, from.y - 2 * minDistance)]
}
return [new Point(to.x, from.y)]
}
} else {
if (to.direction === Direction.Left ||
(to.direction === Direction.Up && from.y < to.y) ||
(to.direction === Direction.Bottom && from.y > to.y)) {
return [new Point(to.x, from.y)];
}
return [new Point(from.x, to.y)];
}
// The to point is on the right.
}
else {
if (to.direction === Direction.Right) {
if (from.y < to.y) {
return getVerticalPoints(from, to);
}
else {
var pts = getVerticalPoints(to, from);
return [pts[1], pts[0]];
}
}
else {
return [new Point(from.x, to.y)];
}
}
}
function getNextPointByRight(from, to) {
if (from.x === to.x || from.y === to.y) {
return [];
return [new Point(to.x, from.y)]
}
return [new Point(from.x, to.y)]
}
// The to point is on the right.
if (from.x < to.x) {
if (to.direction === Direction.Right && to.x - from.x > 3 * minDistance) {
if (from.y < to.y) {
if (to.y - from.y < minDistance) {
return [new Point(from.x, from.y - 2 * minDistance), new Point(to.x, from.y - 2 * minDistance)];
}
return [new Point(to.x, from.y)];
}
else {
if (from.y - to.y < minDistance) {
return [new Point(from.x, from.y + 2 * minDistance), new Point(to.x, from.y + 2 * minDistance)];
}
return [new Point(to.x, from.y)];
}
} else {
if (to.direction === Direction.Right) {
if (from.y < to.y) {
return getVerticalPoints(from, to)
} else {
const pts = getVerticalPoints(to, from)
return [pts[1], pts[0]]
}
} else {
return [new Point(from.x, to.y)]
}
}
}
function getNextPointByRight (from, to) {
if (from.x === to.x || from.y === to.y) {
return []
}
// The to point is on the right.
if (from.x < to.x) {
if (to.direction === Direction.Right && to.x - from.x > 3 * minDistance) {
if (from.y < to.y) {
if (to.y - from.y < minDistance) {
return [new Point(from.x, from.y - 2 * minDistance), new Point(to.x, from.y - 2 * minDistance)]
}
else {
if (to.direction === Direction.Right ||
return [new Point(to.x, from.y)]
} else {
if (from.y - to.y < minDistance) {
return [new Point(from.x, from.y + 2 * minDistance), new Point(to.x, from.y + 2 * minDistance)]
}
return [new Point(to.x, from.y)]
}
} else {
if (to.direction === Direction.Right ||
(to.direction === Direction.Up && from.y < to.y) ||
(to.direction === Direction.Bottom && from.y > to.y)) {
return [new Point(to.x, from.y)];
}
return [new Point(from.x, to.y)];
}
// The to point is on the left.
return [new Point(to.x, from.y)]
}
return [new Point(from.x, to.y)]
}
else {
if (to.direction === Direction.Left) {
if (from.y < to.y) {
return getVerticalPoints(from, to);
}
else {
var pts = getVerticalPoints(to, from);
return [pts[1], pts[0]];
}
}
else {
return [new Point(from.x, to.y)];
}
// The to point is on the left.
} else {
if (to.direction === Direction.Left) {
if (from.y < to.y) {
return getVerticalPoints(from, to)
} else {
const pts = getVerticalPoints(to, from)
return [pts[1], pts[0]]
}
} else {
return [new Point(from.x, to.y)]
}
}
}
function getHorizontalPoints(left, right) {
var x = left.x + (right.x - left.x) / 2;
return [new Point(x, left.y), new Point(x, right.y)];
function getHorizontalPoints (left, right) {
const x = left.x + (right.x - left.x) / 2
return [new Point(x, left.y), new Point(x, right.y)]
}
function getVerticalPoints(up, bottom) {
var y = up.y + (bottom.y - up.y) / 2;
return [new Point(up.x, y), new Point(bottom.x, y)];
function getVerticalPoints (up, bottom) {
const y = up.y + (bottom.y - up.y) / 2
return [new Point(up.x, y), new Point(bottom.x, y)]
}
//# sourceMappingURL=polyline.js.map
// # sourceMappingURL=polyline.js.map

View File

@@ -1,7 +1,7 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function arrowAnchors(node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left));
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right));
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function arrowAnchors (node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left))
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right))
}
//# sourceMappingURL=arrow.anchor.js.map
// # sourceMappingURL=arrow.anchor.js.map

View File

@@ -1,45 +1,45 @@
export function leftArrow(ctx, node) {
ctx.beginPath();
ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 2);
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y);
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3);
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 3);
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 3);
// ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3);
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3);
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3);
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height);
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function leftArrow (ctx, node) {
ctx.beginPath()
ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 2)
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y)
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3)
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 3)
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 3)
// ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3);
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3)
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3)
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height)
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
export function rightArrow(ctx, node) {
ctx.beginPath();
ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 3);
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height / 3);
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y);
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2);
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height);
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3);
ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 2) / 3);
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function rightArrow (ctx, node) {
ctx.beginPath()
ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 3)
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height / 3)
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y)
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2)
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height)
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3)
ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 2) / 3)
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
export function twowayArrow(ctx, node) {
ctx.beginPath();
ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 2);
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y);
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3);
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height / 3);
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y);
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2);
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height);
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3);
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3);
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height);
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function twowayArrow (ctx, node) {
ctx.beginPath()
ctx.moveTo(node.rect.x, node.rect.y + node.rect.height / 2)
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y)
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3)
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height / 3)
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y)
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2)
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + node.rect.height)
ctx.lineTo(node.rect.x + (node.rect.width - node.rect.height / 2), node.rect.y + (node.rect.height * 2) / 3)
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + (node.rect.height * 2) / 3)
ctx.lineTo(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height)
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=arrow.js.map
// # sourceMappingURL=arrow.js.map

View File

@@ -1,23 +1,23 @@
import { Rect } from '../../models/rect';
export function leftArrowIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
import { Rect } from '../../models/rect'
export function leftArrowIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function leftArrowTextRect(node) {
node.textRect = new Rect(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height / 2, node.rect.height / 3);
node.fullTextRect = node.textRect;
export function leftArrowTextRect (node) {
node.textRect = new Rect(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height / 2, node.rect.height / 3)
node.fullTextRect = node.textRect
}
export function rightArrowIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
export function rightArrowIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function rightArrowTextRect(node) {
node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height / 2, node.rect.height / 3);
node.fullTextRect = node.textRect;
export function rightArrowTextRect (node) {
node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height / 2, node.rect.height / 3)
node.fullTextRect = node.textRect
}
export function twowayArrowIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
export function twowayArrowIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function twowayArrowTextRect(node) {
node.textRect = new Rect(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height, node.rect.height / 3);
node.fullTextRect = node.textRect;
export function twowayArrowTextRect (node) {
node.textRect = new Rect(node.rect.x + node.rect.height / 2, node.rect.y + node.rect.height / 3, node.rect.width - node.rect.height, node.rect.height / 3)
node.fullTextRect = node.textRect
}
//# sourceMappingURL=arrow.rect.js.map
// # sourceMappingURL=arrow.rect.js.map

View File

@@ -1,18 +1,18 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function circleAnchors(node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up));
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom));
for (var i = 5; i < 360; i += 5) {
if (i % 90 === 0) {
continue;
}
var direction = Math.round(i / 90);
var pt = new Point(node.rect.center.x + (Math.sin((i / 180) * Math.PI) * node.rect.width) / 2, node.rect.center.y + (Math.cos((i / 180) * Math.PI) * node.rect.height) / 2, direction);
pt.hidden = true;
node.anchors.push(pt);
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function circleAnchors (node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left))
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up))
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right))
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom))
for (let i = 5; i < 360; i += 5) {
if (i % 90 === 0) {
continue
}
const direction = Math.round(i / 90)
const pt = new Point(node.rect.center.x + (Math.sin((i / 180) * Math.PI) * node.rect.width) / 2, node.rect.center.y + (Math.cos((i / 180) * Math.PI) * node.rect.height) / 2, direction)
pt.hidden = true
node.anchors.push(pt)
}
}
//# sourceMappingURL=circle.anchor.js.map
// # sourceMappingURL=circle.anchor.js.map

View File

@@ -1,7 +1,7 @@
export function circle(ctx, node) {
ctx.beginPath();
ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 2, node.rect.height / 2, 0, 0, Math.PI * 2);
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function circle (ctx, node) {
ctx.beginPath()
ctx.ellipse(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 2, node.rect.width / 2, node.rect.height / 2, 0, 0, Math.PI * 2);
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=circle.js.map
// # sourceMappingURL=circle.js.map

View File

@@ -1,27 +1,26 @@
import { Rect } from '../../models/rect';
export function circleIconRect(node) {
var w = node.rect.width / 2;
var h = node.rect.height / 2;
if (w > h) {
w = h;
}
else {
h = w;
}
var top = node.rect.height / 10;
if (top < 10) {
top = 10;
}
node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h);
import { Rect } from '../../models/rect'
export function circleIconRect (node) {
let w = node.rect.width / 2
let h = node.rect.height / 2
if (w > h) {
w = h
} else {
h = w
}
let top = node.rect.height / 10
if (top < 10) {
top = 10
}
node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h)
}
export function circleTextRect(node) {
var bottom = node.rect.height / 20;
if (bottom < 5) {
bottom = 0;
}
node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + (node.rect.height * 2) / 3 - bottom, node.rect.width / 2, node.rect.height / 3 - 5);
var w = (node.rect.width * 5) / 7;
var h = (node.rect.height * 5) / 7;
node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h);
export function circleTextRect (node) {
let bottom = node.rect.height / 20
if (bottom < 5) {
bottom = 0
}
node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + (node.rect.height * 2) / 3 - bottom, node.rect.width / 2, node.rect.height / 3 - 5)
const w = (node.rect.width * 5) / 7
const h = (node.rect.height * 5) / 7
node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h)
}
//# sourceMappingURL=circle.rect.js.map
// # sourceMappingURL=circle.rect.js.map

View File

@@ -1,9 +1,9 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function cloudAnchors(node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 3) / 5, Direction.Left));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 9, Direction.Up));
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 5, Direction.Right));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + (node.rect.height * 4) / 5, Direction.Bottom));
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function cloudAnchors (node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 3) / 5, Direction.Left))
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height / 9, Direction.Up))
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 5, Direction.Right))
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + (node.rect.height * 4) / 5, Direction.Bottom))
}
//# sourceMappingURL=cloud.anchor.js.map
// # sourceMappingURL=cloud.anchor.js.map

View File

@@ -1,11 +1,11 @@
export function cloud(ctx, node) {
ctx.beginPath();
ctx.moveTo(node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 13) / 16);
ctx.bezierCurveTo(node.rect.x - node.rect.width / 15, node.rect.y + (node.rect.height * 13) / 16, node.rect.x - node.rect.width / 15, node.rect.y + (node.rect.height * 7) / 16, node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 7) / 16);
ctx.bezierCurveTo(node.rect.x + node.rect.width / 5, node.rect.y, node.rect.x + (node.rect.width * 4) / 5, node.rect.y, node.rect.x + (node.rect.width * 4) / 5, node.rect.y + (node.rect.height * 7) / 16);
ctx.bezierCurveTo(node.rect.x + (node.rect.width * 16) / 15, node.rect.y + (node.rect.height * 7) / 16, node.rect.x + (node.rect.width * 16) / 15, node.rect.y + (node.rect.height * 13) / 16, node.rect.x + (node.rect.width * 4) / 5, node.rect.y + (node.rect.height * 13) / 16);
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function cloud (ctx, node) {
ctx.beginPath()
ctx.moveTo(node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 13) / 16)
ctx.bezierCurveTo(node.rect.x - node.rect.width / 15, node.rect.y + (node.rect.height * 13) / 16, node.rect.x - node.rect.width / 15, node.rect.y + (node.rect.height * 7) / 16, node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 7) / 16)
ctx.bezierCurveTo(node.rect.x + node.rect.width / 5, node.rect.y, node.rect.x + (node.rect.width * 4) / 5, node.rect.y, node.rect.x + (node.rect.width * 4) / 5, node.rect.y + (node.rect.height * 7) / 16)
ctx.bezierCurveTo(node.rect.x + (node.rect.width * 16) / 15, node.rect.y + (node.rect.height * 7) / 16, node.rect.x + (node.rect.width * 16) / 15, node.rect.y + (node.rect.height * 13) / 16, node.rect.x + (node.rect.width * 4) / 5, node.rect.y + (node.rect.height * 13) / 16)
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=cloud.js.map
// # sourceMappingURL=cloud.js.map

View File

@@ -1,9 +1,9 @@
import { Rect } from '../../models/rect';
export function cloudIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
import { Rect } from '../../models/rect'
export function cloudIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function cloudTextRect(node) {
node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + node.rect.height / 4, node.rect.width / 2, (node.rect.height * 6) / 11);
node.fullTextRect = node.textRect;
export function cloudTextRect (node) {
node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + node.rect.height / 4, node.rect.width / 2, (node.rect.height * 6) / 11)
node.fullTextRect = node.textRect
}
//# sourceMappingURL=cloud.rect.js.map
// # sourceMappingURL=cloud.rect.js.map

View File

@@ -1,10 +1,10 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function cubeAnchors(node) {
var offset = node.z * Math.sin((45 * Math.PI) / 180);
node.anchors.push(new Point(node.rect.x, node.rect.ey - (node.rect.height - offset) / 2, Direction.Left));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + offset / 2, Direction.Up));
node.anchors.push(new Point(node.rect.ex - offset / 2, node.rect.y + node.rect.height / 2, Direction.Right));
node.anchors.push(new Point(node.rect.x + (node.rect.width - offset) / 2, node.rect.y + node.rect.height, Direction.Bottom));
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function cubeAnchors (node) {
const offset = node.z * Math.sin((45 * Math.PI) / 180)
node.anchors.push(new Point(node.rect.x, node.rect.ey - (node.rect.height - offset) / 2, Direction.Left))
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + offset / 2, Direction.Up))
node.anchors.push(new Point(node.rect.ex - offset / 2, node.rect.y + node.rect.height / 2, Direction.Right))
node.anchors.push(new Point(node.rect.x + (node.rect.width - offset) / 2, node.rect.y + node.rect.height, Direction.Bottom))
}
//# sourceMappingURL=cube.anchor.js.map
// # sourceMappingURL=cube.anchor.js.map

View File

@@ -1,5 +1,5 @@
import { Cube } from './cube.model';
export function cube(ctx, node) {
new Cube(node.rect, node.z, node.zRotate, node.fillStyle, node.strokeStyle).render(ctx);
import { Cube } from './cube.model'
export function cube (ctx, node) {
new Cube(node.rect, node.z, node.zRotate, node.fillStyle, node.strokeStyle).render(ctx)
}
//# sourceMappingURL=cube.js.map
// # sourceMappingURL=cube.js.map

View File

@@ -1,64 +1,63 @@
import { Point } from '../../models/point';
import { pSBC } from '../../utils/math';
var Surface = /** @class */ (function () {
function Surface(pt1, pt2, pt3, pt4, fillStyle, strokeStyle) {
if (fillStyle === void 0) { fillStyle = ''; }
if (strokeStyle === void 0) { strokeStyle = ''; }
this.points = [];
this.fillStyle = '';
this.strokeStyle = '';
this.points.push(pt1);
this.points.push(pt2);
this.points.push(pt3);
this.points.push(pt4);
this.fillStyle = fillStyle;
this.strokeStyle = strokeStyle || fillStyle;
import { Point } from '../../models/point'
import { pSBC } from '../../utils/math'
const Surface = /** @class */ (function () {
function Surface (pt1, pt2, pt3, pt4, fillStyle, strokeStyle) {
if (fillStyle === void 0) { fillStyle = '' }
if (strokeStyle === void 0) { strokeStyle = '' }
this.points = []
this.fillStyle = ''
this.strokeStyle = ''
this.points.push(pt1)
this.points.push(pt2)
this.points.push(pt3)
this.points.push(pt4)
this.fillStyle = fillStyle
this.strokeStyle = strokeStyle || fillStyle
}
Surface.prototype.render = function (ctx) {
ctx.save()
ctx.fillStyle = this.fillStyle
ctx.strokeStyle = this.strokeStyle
ctx.beginPath()
for (let i = 0; i < this.points.length; ++i) {
if (i) {
ctx.lineTo(this.points[i].x, this.points[i].y)
} else {
ctx.moveTo(this.points[i].x, this.points[i].y)
}
}
Surface.prototype.render = function (ctx) {
ctx.save();
ctx.fillStyle = this.fillStyle;
ctx.strokeStyle = this.strokeStyle;
ctx.beginPath();
for (var i = 0; i < this.points.length; ++i) {
if (i) {
ctx.lineTo(this.points[i].x, this.points[i].y);
}
else {
ctx.moveTo(this.points[i].x, this.points[i].y);
}
}
ctx.closePath();
this.fillStyle && ctx.fill();
ctx.stroke();
ctx.restore();
};
return Surface;
}());
export { Surface };
var Cube = /** @class */ (function () {
function Cube(rect, z, zRotate, fillStyle, strokeStyle) {
if (fillStyle === void 0) { fillStyle = '#ddd'; }
if (strokeStyle === void 0) { strokeStyle = '#ccc'; }
this.surfaces = [];
var offset = z * Math.sin((45 * Math.PI) / 180);
var p1 = new Point(rect.x, rect.y + offset);
var p2 = new Point(rect.ex - offset, rect.y + offset);
var p3 = new Point(rect.ex - offset, rect.ey);
var p4 = new Point(rect.x, rect.ey);
// front
this.surfaces.push(new Surface(p1, p2, p3, p4, fillStyle, strokeStyle));
// up
this.surfaces.push(new Surface(p1, new Point(rect.x + offset, rect.y), new Point(rect.ex, rect.y), p2, pSBC(0.5, fillStyle), strokeStyle));
// right
this.surfaces.push(new Surface(p2, new Point(rect.ex, rect.y), new Point(rect.ex, rect.ey - offset), p3, pSBC(0.6, fillStyle), strokeStyle));
ctx.closePath()
this.fillStyle && ctx.fill()
ctx.stroke()
ctx.restore()
}
return Surface
}())
export { Surface }
const Cube = /** @class */ (function () {
function Cube (rect, z, zRotate, fillStyle, strokeStyle) {
if (fillStyle === void 0) { fillStyle = '#ddd' }
if (strokeStyle === void 0) { strokeStyle = '#ccc' }
this.surfaces = []
const offset = z * Math.sin((45 * Math.PI) / 180)
const p1 = new Point(rect.x, rect.y + offset)
const p2 = new Point(rect.ex - offset, rect.y + offset)
const p3 = new Point(rect.ex - offset, rect.ey)
const p4 = new Point(rect.x, rect.ey)
// front
this.surfaces.push(new Surface(p1, p2, p3, p4, fillStyle, strokeStyle))
// up
this.surfaces.push(new Surface(p1, new Point(rect.x + offset, rect.y), new Point(rect.ex, rect.y), p2, pSBC(0.5, fillStyle), strokeStyle))
// right
this.surfaces.push(new Surface(p2, new Point(rect.ex, rect.y), new Point(rect.ex, rect.ey - offset), p3, pSBC(0.6, fillStyle), strokeStyle))
}
Cube.prototype.render = function (ctx) {
for (let _i = 0, _a = this.surfaces; _i < _a.length; _i++) {
const item = _a[_i]
item.render(ctx)
}
Cube.prototype.render = function (ctx) {
for (var _i = 0, _a = this.surfaces; _i < _a.length; _i++) {
var item = _a[_i];
item.render(ctx);
}
};
return Cube;
}());
export { Cube };
//# sourceMappingURL=cube.model.js.map
}
return Cube
}())
export { Cube }
// # sourceMappingURL=cube.model.js.map

View File

@@ -1,11 +1,11 @@
import { Rect } from '../../models/rect';
export function cubeIconRect(node) {
node.fullIconRect = node.fullTextRect;
node.iconRect = new Rect(node.fullIconRect.x, node.fullIconRect.y, node.fullIconRect.width, (node.fullIconRect.height * 2) / 3);
import { Rect } from '../../models/rect'
export function cubeIconRect (node) {
node.fullIconRect = node.fullTextRect
node.iconRect = new Rect(node.fullIconRect.x, node.fullIconRect.y, node.fullIconRect.width, (node.fullIconRect.height * 2) / 3)
}
export function cubeTextRect(node) {
var offset = node.z * Math.sin((45 * Math.PI) / 180);
node.fullTextRect = new Rect(node.rect.x, node.rect.y + offset, node.rect.width - offset, node.rect.height - offset);
node.textRect = new Rect(node.fullTextRect.x + 10, node.fullTextRect.y + (node.fullTextRect.height * 2) / 3, node.fullTextRect.width - 20, node.fullTextRect.height / 3 - 5);
export function cubeTextRect (node) {
const offset = node.z * Math.sin((45 * Math.PI) / 180)
node.fullTextRect = new Rect(node.rect.x, node.rect.y + offset, node.rect.width - offset, node.rect.height - offset)
node.textRect = new Rect(node.fullTextRect.x + 10, node.fullTextRect.y + (node.fullTextRect.height * 2) / 3, node.fullTextRect.width - 20, node.fullTextRect.height / 3 - 5)
}
//# sourceMappingURL=cube.rect.js.map
// # sourceMappingURL=cube.rect.js.map

View File

@@ -1,11 +1,11 @@
export function diamond(ctx, node) {
ctx.beginPath();
ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y);
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2);
ctx.lineTo(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height);
ctx.lineTo(node.rect.x, node.rect.y + node.rect.height / 2);
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function diamond (ctx, node) {
ctx.beginPath()
ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y)
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2)
ctx.lineTo(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height)
ctx.lineTo(node.rect.x, node.rect.y + node.rect.height / 2)
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=diamond.js.map
// # sourceMappingURL=diamond.js.map

View File

@@ -1,27 +1,26 @@
import { Rect } from '../../models/rect';
export function diamondIconRect(node) {
var w = node.rect.width / 3;
var h = node.rect.height / 3;
if (w > h) {
w = h;
}
else {
h = w;
}
var top = node.rect.width / 5;
if (top < 10) {
top = 10;
}
node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h);
import { Rect } from '../../models/rect'
export function diamondIconRect (node) {
let w = node.rect.width / 3
let h = node.rect.height / 3
if (w > h) {
w = h
} else {
h = w
}
let top = node.rect.width / 5
if (top < 10) {
top = 10
}
node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h)
}
export function diamondTextRect(node) {
var bottom = node.rect.height / 10;
if (bottom < 5) {
bottom = 0;
}
node.textRect = new Rect(node.rect.x + node.rect.width / 3, node.rect.y + (node.rect.height * 2) / 3 - bottom, node.rect.width / 3, node.rect.height / 3 - 5);
var w = node.rect.width / 2;
var h = (node.rect.height * 1) / 2;
node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 4, w, h);
export function diamondTextRect (node) {
let bottom = node.rect.height / 10
if (bottom < 5) {
bottom = 0
}
node.textRect = new Rect(node.rect.x + node.rect.width / 3, node.rect.y + (node.rect.height * 2) / 3 - bottom, node.rect.width / 3, node.rect.height / 3 - 5)
const w = node.rect.width / 2
const h = (node.rect.height * 1) / 2
node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 4, w, h)
}
//# sourceMappingURL=diamond.rect.js.map
// # sourceMappingURL=diamond.rect.js.map

View File

@@ -1,16 +1,16 @@
export function file(ctx, node) {
ctx.beginPath();
var offsetX = node.rect.width / 6;
ctx.moveTo(node.rect.x, node.rect.y);
ctx.lineTo(node.rect.ex - offsetX, node.rect.y);
ctx.lineTo(node.rect.ex, node.rect.y + offsetX);
ctx.lineTo(node.rect.ex, node.rect.ey);
ctx.lineTo(node.rect.x, node.rect.ey);
ctx.closePath();
ctx.moveTo(node.rect.ex - offsetX, node.rect.y);
ctx.lineTo(node.rect.ex - offsetX, node.rect.y + offsetX);
ctx.lineTo(node.rect.ex, node.rect.y + offsetX);
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function file (ctx, node) {
ctx.beginPath()
const offsetX = node.rect.width / 6
ctx.moveTo(node.rect.x, node.rect.y)
ctx.lineTo(node.rect.ex - offsetX, node.rect.y)
ctx.lineTo(node.rect.ex, node.rect.y + offsetX)
ctx.lineTo(node.rect.ex, node.rect.ey)
ctx.lineTo(node.rect.x, node.rect.ey)
ctx.closePath()
ctx.moveTo(node.rect.ex - offsetX, node.rect.y)
ctx.lineTo(node.rect.ex - offsetX, node.rect.y + offsetX)
ctx.lineTo(node.rect.ex, node.rect.y + offsetX);
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=file.js.map
// # sourceMappingURL=file.js.map

View File

@@ -1,18 +1,17 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function graffitiAnchors(node) {
if (!node.points || !node.points.length) {
return;
}
var pt1 = node.points[0];
var pt2 = node.points[node.points.length - 1];
if (pt1.x < pt2.x) {
node.anchors.push(new Point(pt1.x, pt1.y, Direction.Left));
node.anchors.push(new Point(pt2.x, pt2.y, Direction.Right));
}
else {
node.anchors.push(new Point(pt1.x, pt1.y, Direction.Right));
node.anchors.push(new Point(pt2.x, pt2.y, Direction.Left));
}
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function graffitiAnchors (node) {
if (!node.points || !node.points.length) {
return
}
const pt1 = node.points[0]
const pt2 = node.points[node.points.length - 1]
if (pt1.x < pt2.x) {
node.anchors.push(new Point(pt1.x, pt1.y, Direction.Left))
node.anchors.push(new Point(pt2.x, pt2.y, Direction.Right))
} else {
node.anchors.push(new Point(pt1.x, pt1.y, Direction.Right))
node.anchors.push(new Point(pt2.x, pt2.y, Direction.Left))
}
}
//# sourceMappingURL=graffiti.anchor.js.map
// # sourceMappingURL=graffiti.anchor.js.map

View File

@@ -1,14 +1,14 @@
export function graffiti(ctx, node) {
if (!node.points || !node.points[0]) {
return;
}
ctx.beginPath();
ctx.moveTo(node.points[0].x, node.points[0].y);
node.points.forEach(function (pt) {
ctx.lineTo(pt.x, pt.y);
});
node['closePath'] && !node['doing'] && ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function graffiti (ctx, node) {
if (!node.points || !node.points[0]) {
return
}
ctx.beginPath()
ctx.moveTo(node.points[0].x, node.points[0].y)
node.points.forEach(function (pt) {
ctx.lineTo(pt.x, pt.y)
})
node.closePath && !node.doing && ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=graffiti.js.map
// # sourceMappingURL=graffiti.js.map

View File

@@ -1,21 +1,21 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function hexagonAnchors(node) {
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up));
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom));
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left));
var ptLT = new Point(node.rect.x + node.rect.width / 10, node.rect.y + node.rect.height / 4, Direction.Left);
ptLT.hidden = true;
node.anchors.push(ptLT);
var ptRT = new Point(node.rect.x + node.rect.width / 10, node.rect.y + (node.rect.height * 3) / 4, Direction.Left);
ptRT.hidden = true;
node.anchors.push(ptRT);
var ptLB = new Point(node.rect.x + (node.rect.width * 9) / 10, node.rect.y + node.rect.height / 4, Direction.Right);
ptLB.hidden = true;
node.anchors.push(ptLB);
var ptRB = new Point(node.rect.x + (node.rect.width * 9) / 10, node.rect.y + (node.rect.height * 3) / 4, Direction.Right);
ptRB.hidden = true;
node.anchors.push(ptRB);
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function hexagonAnchors (node) {
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up))
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right))
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom))
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left))
const ptLT = new Point(node.rect.x + node.rect.width / 10, node.rect.y + node.rect.height / 4, Direction.Left)
ptLT.hidden = true
node.anchors.push(ptLT)
const ptRT = new Point(node.rect.x + node.rect.width / 10, node.rect.y + (node.rect.height * 3) / 4, Direction.Left)
ptRT.hidden = true
node.anchors.push(ptRT)
const ptLB = new Point(node.rect.x + (node.rect.width * 9) / 10, node.rect.y + node.rect.height / 4, Direction.Right)
ptLB.hidden = true
node.anchors.push(ptLB)
const ptRB = new Point(node.rect.x + (node.rect.width * 9) / 10, node.rect.y + (node.rect.height * 3) / 4, Direction.Right)
ptRB.hidden = true
node.anchors.push(ptRB)
}
//# sourceMappingURL=hexagon.anchor.js.map
// # sourceMappingURL=hexagon.anchor.js.map

View File

@@ -1,14 +1,14 @@
export function hexagon(ctx, node) {
ctx.beginPath();
var pos = node.rect.width / 5;
ctx.moveTo(node.rect.x + pos, node.rect.y);
ctx.lineTo(node.rect.x + node.rect.width - pos, node.rect.y);
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2);
ctx.lineTo(node.rect.x + node.rect.width - pos, node.rect.y + node.rect.height);
ctx.lineTo(node.rect.x + pos, node.rect.y + node.rect.height);
ctx.lineTo(node.rect.x, node.rect.y + node.rect.height / 2);
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function hexagon (ctx, node) {
ctx.beginPath()
const pos = node.rect.width / 5
ctx.moveTo(node.rect.x + pos, node.rect.y)
ctx.lineTo(node.rect.x + node.rect.width - pos, node.rect.y)
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2)
ctx.lineTo(node.rect.x + node.rect.width - pos, node.rect.y + node.rect.height)
ctx.lineTo(node.rect.x + pos, node.rect.y + node.rect.height)
ctx.lineTo(node.rect.x, node.rect.y + node.rect.height / 2)
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=hexagon.js.map
// # sourceMappingURL=hexagon.js.map

View File

@@ -1,14 +1,14 @@
import { Rect } from '../../models/rect';
export function hexagonIconRect(node) {
var w = (node.rect.width * 3) / 5;
var h = (node.rect.height * 3) / 4;
node.iconRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, h - node.paddingTopNum - node.paddingBottomNum);
node.fullIconRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum);
import { Rect } from '../../models/rect'
export function hexagonIconRect (node) {
const w = (node.rect.width * 3) / 5
const h = (node.rect.height * 3) / 4
node.iconRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, h - node.paddingTopNum - node.paddingBottomNum)
node.fullIconRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum)
}
export function hexagonTextRect(node) {
var w = (node.rect.width * 3) / 5;
var h = node.rect.height / 4;
node.textRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.rect.height - h + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, h);
node.fullTextRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum);
export function hexagonTextRect (node) {
const w = (node.rect.width * 3) / 5
const h = node.rect.height / 4
node.textRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.rect.height - h + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, h)
node.fullTextRect = new Rect(node.rect.x + node.rect.width / 5 + node.paddingLeftNum, node.rect.y + node.paddingTopNum, w - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum)
}
//# sourceMappingURL=hexagon.rect.js.map
// # sourceMappingURL=hexagon.rect.js.map

View File

@@ -1,19 +1,18 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function imageAnchors(node) {
var textWidth = 0;
var textHeight = 0;
if (node.text) {
if (node.paddingRightNum) {
textWidth = node.paddingRightNum;
}
else {
textHeight = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1);
}
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function imageAnchors (node) {
let textWidth = 0
let textHeight = 0
if (node.text) {
if (node.paddingRightNum) {
textWidth = node.paddingRightNum
} else {
textHeight = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1)
}
node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height - textHeight) / 2, Direction.Left));
node.anchors.push(new Point(node.rect.x + (node.rect.width - textWidth) / 2, node.rect.y, Direction.Up));
node.anchors.push(new Point(node.rect.x + node.rect.width - textWidth, node.rect.y + (node.rect.height - textHeight) / 2, Direction.Right));
node.anchors.push(new Point(node.rect.x + (node.rect.width - textWidth) / 2, node.rect.y + node.rect.height - textHeight, Direction.Bottom));
}
node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height - textHeight) / 2, Direction.Left))
node.anchors.push(new Point(node.rect.x + (node.rect.width - textWidth) / 2, node.rect.y, Direction.Up))
node.anchors.push(new Point(node.rect.x + node.rect.width - textWidth, node.rect.y + (node.rect.height - textHeight) / 2, Direction.Right))
node.anchors.push(new Point(node.rect.x + (node.rect.width - textWidth) / 2, node.rect.y + node.rect.height - textHeight, Direction.Bottom))
}
//# sourceMappingURL=image.anchor.js.map
// # sourceMappingURL=image.anchor.js.map

View File

@@ -1,27 +1,25 @@
import { Rect } from '../../models/rect';
export function imageIconRect(node) {
var textWidth = 0;
var textHeight = 0;
if (node.text) {
if (node.paddingRightNum) {
textWidth = node.paddingRightNum;
}
else {
textHeight = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1);
}
}
node.iconRect = new Rect(node.rect.x, node.rect.y, node.rect.width - textWidth, node.rect.height - textHeight);
node.fullIconRect = node.rect;
}
export function imageTextRect(node) {
import { Rect } from '../../models/rect'
export function imageIconRect (node) {
let textWidth = 0
let textHeight = 0
if (node.text) {
if (node.paddingRightNum) {
var width = node.paddingRightNum - 5;
node.textRect = new Rect(node.rect.x + node.rect.width - width, node.rect.y, width, node.rect.height - node.textOffsetY * 2);
textWidth = node.paddingRightNum
} else {
textHeight = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1)
}
else {
var height = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1);
node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height - height, node.rect.width - node.textOffsetX * 2, height);
}
node.fullTextRect = node.rect;
}
node.iconRect = new Rect(node.rect.x, node.rect.y, node.rect.width - textWidth, node.rect.height - textHeight)
node.fullIconRect = node.rect
}
//# sourceMappingURL=image.rect.js.map
export function imageTextRect (node) {
if (node.paddingRightNum) {
const width = node.paddingRightNum - 5
node.textRect = new Rect(node.rect.x + node.rect.width - width, node.rect.y, width, node.rect.height - node.textOffsetY * 2)
} else {
const height = node.paddingBottomNum || node.lineHeight * node.fontSize * (node.textMaxLine || 1)
node.textRect = new Rect(node.rect.x, node.rect.y + node.rect.height - height, node.rect.width - node.textOffsetX * 2, height)
}
node.fullTextRect = node.rect
}
// # sourceMappingURL=image.rect.js.map

View File

@@ -1,14 +1,14 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function lineAnchors(node) {
var y = node.rect.y + node.rect.height / 2;
node.anchors.push(new Point(node.rect.x, y, Direction.Left));
node.anchors.push(new Point(node.rect.x + node.rect.width, y, Direction.Right));
var scale = topology.data.scale || 1; // 取全局的 scale 属性
for (var i = node.rect.x + 5 * scale; i < node.rect.ex; i += 5 * scale) {
var pt = new Point(i, y, Direction.Bottom);
pt.hidden = true;
node.anchors.push(pt);
}
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function lineAnchors (node) {
const y = node.rect.y + node.rect.height / 2
node.anchors.push(new Point(node.rect.x, y, Direction.Left))
node.anchors.push(new Point(node.rect.x + node.rect.width, y, Direction.Right))
const scale = topology.data.scale || 1 // 取全局的 scale 属性
for (let i = node.rect.x + 5 * scale; i < node.rect.ex; i += 5 * scale) {
const pt = new Point(i, y, Direction.Bottom)
pt.hidden = true
node.anchors.push(pt)
}
}
//# sourceMappingURL=line.anchor.js.map
// # sourceMappingURL=line.anchor.js.map

View File

@@ -1,8 +1,8 @@
export function line(ctx, node) {
ctx.beginPath();
var y = node.rect.y + node.rect.height / 2;
ctx.moveTo(node.rect.x, y);
ctx.lineTo(node.rect.x + node.rect.width, y);
ctx.stroke();
export function line (ctx, node) {
ctx.beginPath()
const y = node.rect.y + node.rect.height / 2
ctx.moveTo(node.rect.x, y)
ctx.lineTo(node.rect.x + node.rect.width, y)
ctx.stroke()
}
//# sourceMappingURL=line.js.map
// # sourceMappingURL=line.js.map

View File

@@ -1,9 +1,9 @@
import { Rect } from '../../models/rect';
export function lineIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
import { Rect } from '../../models/rect'
export function lineIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function lineTextRect(node) {
node.fullTextRect = new Rect(node.rect.x + 10, node.rect.y + node.rect.height / 2 - 20, node.rect.width - 20, 20);
node.textRect = node.fullTextRect;
export function lineTextRect (node) {
node.fullTextRect = new Rect(node.rect.x + 10, node.rect.y + node.rect.height / 2 - 20, node.rect.width - 20, 20)
node.textRect = node.fullTextRect
}
//# sourceMappingURL=line.rect.js.map
// # sourceMappingURL=line.rect.js.map

View File

@@ -1,27 +1,25 @@
export function lines(ctx, node) {
if (!node.points || !node.points[1]) {
return;
export function lines (ctx, node) {
if (!node.points || !node.points[1]) {
return
}
ctx.beginPath()
ctx.moveTo(node.points[0].x, node.points[0].y)
for (let i = 1; i < node.points.length;) {
// curve 控制点
if (node.points[i].data) {
if (node.points[i + 2]) {
ctx.bezierCurveTo(node.points[i].x, node.points[i].y, node.points[i + 1].x, node.points[i + 1].y, node.points[i + 2].x, node.points[i + 2].y)
i += 2
} else {
break
}
} else {
ctx.lineTo(node.points[i].x, node.points[i].y)
++i
}
ctx.beginPath();
ctx.moveTo(node.points[0].x, node.points[0].y);
for (var i = 1; i < node.points.length;) {
// curve 控制点
if (node.points[i].data) {
if (node.points[i + 2]) {
ctx.bezierCurveTo(node.points[i].x, node.points[i].y, node.points[i + 1].x, node.points[i + 1].y, node.points[i + 2].x, node.points[i + 2].y);
i += 2;
}
else {
break;
}
}
else {
ctx.lineTo(node.points[i].x, node.points[i].y);
++i;
}
}
node['closePath'] && !node['doing'] && ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
}
node.closePath && !node.doing && ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=lines.js.map
// # sourceMappingURL=lines.js.map

View File

@@ -1,9 +1,9 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function messageAnchors(node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 3) / 8, Direction.Left));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up));
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 8, Direction.Right));
node.anchors.push(new Point(node.rect.x + node.rect.width / 4, node.rect.ey, Direction.Bottom));
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function messageAnchors (node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 3) / 8, Direction.Left))
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up))
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 8, Direction.Right))
node.anchors.push(new Point(node.rect.x + node.rect.width / 4, node.rect.ey, Direction.Bottom))
}
//# sourceMappingURL=message.anchor.js.map
// # sourceMappingURL=message.anchor.js.map

View File

@@ -1,14 +1,14 @@
export function message(ctx, node) {
ctx.beginPath();
ctx.moveTo(node.rect.x, node.rect.y);
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y);
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 4);
ctx.lineTo(node.rect.x + (node.rect.width * 8) / 16, node.rect.y + (node.rect.height * 3) / 4);
ctx.lineTo(node.rect.x + node.rect.width / 4, node.rect.ey);
ctx.lineTo(node.rect.x + (node.rect.width * 5) / 16, node.rect.y + (node.rect.height * 3) / 4);
ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 3) / 4);
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function message (ctx, node) {
ctx.beginPath()
ctx.moveTo(node.rect.x, node.rect.y)
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y)
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 3) / 4)
ctx.lineTo(node.rect.x + (node.rect.width * 8) / 16, node.rect.y + (node.rect.height * 3) / 4)
ctx.lineTo(node.rect.x + node.rect.width / 4, node.rect.ey)
ctx.lineTo(node.rect.x + (node.rect.width * 5) / 16, node.rect.y + (node.rect.height * 3) / 4)
ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 3) / 4)
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=message.js.map
// # sourceMappingURL=message.js.map

View File

@@ -1,10 +1,10 @@
import { Rect } from '../../models/rect';
export function messageIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
node.fullIconRect = node.iconRect;
import { Rect } from '../../models/rect'
export function messageIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
node.fullIconRect = node.iconRect
}
export function messageTextRect(node) {
node.textRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, (node.rect.height * 3) / 4 - node.paddingTopNum - node.paddingBottomNum);
node.fullTextRect = node.textRect;
export function messageTextRect (node) {
node.textRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, (node.rect.height * 3) / 4 - node.paddingTopNum - node.paddingBottomNum)
node.fullTextRect = node.textRect
}
//# sourceMappingURL=message.rect.js.map
// # sourceMappingURL=message.rect.js.map

View File

@@ -1,6 +1,6 @@
import { Point } from '../../models/point';
export function mindLineAnchors(node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height, 4));
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height, 2));
import { Point } from '../../models/point'
export function mindLineAnchors (node) {
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height, 4))
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height, 2))
}
//# sourceMappingURL=mindLine.anchor.js.map
// # sourceMappingURL=mindLine.anchor.js.map

View File

@@ -1,8 +1,8 @@
export function mindLine(ctx, node) {
ctx.beginPath();
ctx.moveTo(node.rect.x, node.rect.y + node.rect.height);
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height);
ctx.closePath();
ctx.stroke();
export function mindLine (ctx, node) {
ctx.beginPath()
ctx.moveTo(node.rect.x, node.rect.y + node.rect.height)
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height)
ctx.closePath()
ctx.stroke()
}
//# sourceMappingURL=mindLine.js.map
// # sourceMappingURL=mindLine.js.map

View File

@@ -1,94 +1,90 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function mindNodeAnchors(node) {
var r = borderRadius(node);
// 上四
var topN = 5; // 上方节点个数,控制位置,实际节点数依然是 4 个
for (var i = 0; i < topN; i++) {
if (i === 2) {
continue;
}
var x = node.rect.x + (node.rect.width * (i + 1)) / (topN + 1);
var y = node.rect.y;
if (x < node.rect.x + r) {
// 在左侧圆角
y = getYByCircle(node.rect.x + r, y + r, x, r, -1);
}
else if (x > node.rect.x + node.rect.width - r) {
// 在右侧圆角
y = getYByCircle(node.rect.x + node.rect.width - r, y + r, x, r, -1);
}
node.anchors.push(new Point(x, y, Direction.Up));
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function mindNodeAnchors (node) {
const r = borderRadius(node)
// 上四
const topN = 5 // 上方节点个数,控制位置,实际节点数依然是 4 个
for (var i = 0; i < topN; i++) {
if (i === 2) {
continue
}
// 右三
var rightN = 3; // 右侧节点数
for (var i = 0; i < rightN; i++) {
var y = node.rect.y + (node.rect.height * (i + 1)) / (rightN + 1);
var x = node.rect.x + node.rect.width;
if (y < node.rect.y + r) {
// 在侧圆角以内
x = getXByCircle(x - r, node.rect.y + r, y, r);
}
else if (y > node.rect.y + node.rect.height - r) {
// 下侧圆角
x = getXByCircle(x - r, node.rect.y + node.rect.height - r, y, r);
}
node.anchors.push(new Point(x, y, Direction.Right));
var x = node.rect.x + (node.rect.width * (i + 1)) / (topN + 1)
var y = node.rect.y
if (x < node.rect.x + r) {
// 在左侧圆角
y = getYByCircle(node.rect.x + r, y + r, x, r, -1)
} else if (x > node.rect.x + node.rect.width - r) {
// 在侧圆角
y = getYByCircle(node.rect.x + node.rect.width - r, y + r, x, r, -1)
}
// 下四
var bottomN = 5; // 下侧节点数
for (var i = 0; i < bottomN; i++) {
if (i === 2) {
continue;
}
var x = node.rect.x + (node.rect.width * (i + 1)) / (bottomN + 1);
var y = node.rect.y + node.rect.height;
if (x < node.rect.x + r) {
// 在左侧圆角
y = getYByCircle(node.rect.x + r, y - r, x, r);
}
else if (x > node.rect.x + node.rect.width - r) {
// 在右侧圆角
y = getYByCircle(node.rect.x + node.rect.width - r, y - r, x, r);
}
node.anchors.push(new Point(x, y, Direction.Bottom));
node.anchors.push(new Point(x, y, Direction.Up))
}
// 右三
const rightN = 3 // 右侧节点数
for (var i = 0; i < rightN; i++) {
var y = node.rect.y + (node.rect.height * (i + 1)) / (rightN + 1)
var x = node.rect.x + node.rect.width
if (y < node.rect.y + r) {
// 在上侧圆角以内
x = getXByCircle(x - r, node.rect.y + r, y, r)
} else if (y > node.rect.y + node.rect.height - r) {
// 下侧圆角
x = getXByCircle(x - r, node.rect.y + node.rect.height - r, y, r)
}
// 左三
var leftN = 3; // 左侧节点数
for (var i = 0; i < leftN; i++) {
var y = node.rect.y + (node.rect.height * (i + 1)) / (leftN + 1);
var x = node.rect.x;
if (y < node.rect.y + r) {
// 在上侧圆角以内
x = getXByCircle(x + r, node.rect.y + r, y, r, -1);
}
else if (y > node.rect.y + node.rect.height - r) {
// 下侧圆角
x = getXByCircle(x + r, node.rect.y + node.rect.height - r, y, r, -1);
}
node.anchors.push(new Point(x, y, Direction.Left));
node.anchors.push(new Point(x, y, Direction.Right))
}
// 下四
const bottomN = 5 // 下侧节点数
for (var i = 0; i < bottomN; i++) {
if (i === 2) {
continue
}
var x = node.rect.x + (node.rect.width * (i + 1)) / (bottomN + 1)
var y = node.rect.y + node.rect.height
if (x < node.rect.x + r) {
// 在左侧圆角
y = getYByCircle(node.rect.x + r, y - r, x, r)
} else if (x > node.rect.x + node.rect.width - r) {
// 在右侧圆角
y = getYByCircle(node.rect.x + node.rect.width - r, y - r, x, r)
}
node.anchors.push(new Point(x, y, Direction.Bottom))
}
// 左三
const leftN = 3 // 左侧节点数
for (var i = 0; i < leftN; i++) {
var y = node.rect.y + (node.rect.height * (i + 1)) / (leftN + 1)
var x = node.rect.x
if (y < node.rect.y + r) {
// 在上侧圆角以内
x = getXByCircle(x + r, node.rect.y + r, y, r, -1)
} else if (y > node.rect.y + node.rect.height - r) {
// 下侧圆角
x = getXByCircle(x + r, node.rect.y + node.rect.height - r, y, r, -1)
}
node.anchors.push(new Point(x, y, Direction.Left))
}
}
/**
* 得到元素实际计算半径
* @param node 元素
* @returns 元素实际半径
*/
function borderRadius(node) {
var wr = node.borderRadius;
var hr = node.borderRadius;
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius;
hr = node.rect.height * node.borderRadius;
}
var r = wr < hr ? wr : hr;
if (node.rect.width < 2 * r) {
r = node.rect.width / 2;
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2;
}
return r;
function borderRadius (node) {
let wr = node.borderRadius
let hr = node.borderRadius
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius
hr = node.rect.height * node.borderRadius
}
let r = wr < hr ? wr : hr
if (node.rect.width < 2 * r) {
r = node.rect.width / 2
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2
}
return r
}
/**
* 获取圆的 x 坐标
@@ -98,9 +94,9 @@ function borderRadius(node) {
* @param r 半径
* @param sqrt 点可能在左侧,左侧填-1右侧1默认值
*/
function getXByCircle(ox, oy, y, r, sqrt) {
if (sqrt === void 0) { sqrt = 1; }
return sqrt * Math.sqrt(Math.pow(r, 2) - Math.pow((y - oy), 2)) + ox;
function getXByCircle (ox, oy, y, r, sqrt) {
if (sqrt === void 0) { sqrt = 1 }
return sqrt * Math.sqrt(Math.pow(r, 2) - Math.pow((y - oy), 2)) + ox
}
/**
* 获取圆的 y 坐标
@@ -110,8 +106,8 @@ function getXByCircle(ox, oy, y, r, sqrt) {
* @param r 半径
* @param sqrt 点可以在上侧,也可能在下侧,上侧-1下侧1默认
*/
function getYByCircle(ox, oy, x, r, sqrt) {
if (sqrt === void 0) { sqrt = 1; }
return sqrt * Math.sqrt(Math.pow(r, 2) - Math.pow((x - ox), 2)) + oy;
function getYByCircle (ox, oy, x, r, sqrt) {
if (sqrt === void 0) { sqrt = 1 }
return sqrt * Math.sqrt(Math.pow(r, 2) - Math.pow((x - ox), 2)) + oy
}
//# sourceMappingURL=mindNode.anchor.js.map
// # sourceMappingURL=mindNode.anchor.js.map

View File

@@ -1,10 +1,10 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function pentagonAnchors(node) {
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up));
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 5, Direction.Right));
node.anchors.push(new Point(node.rect.x + (node.rect.width * 4) / 5, node.rect.y + node.rect.height, Direction.Bottom));
node.anchors.push(new Point(node.rect.x + node.rect.width / 5, node.rect.y + node.rect.height, Direction.Bottom));
node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 2) / 5, Direction.Left));
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function pentagonAnchors (node) {
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up))
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 5, Direction.Right))
node.anchors.push(new Point(node.rect.x + (node.rect.width * 4) / 5, node.rect.y + node.rect.height, Direction.Bottom))
node.anchors.push(new Point(node.rect.x + node.rect.width / 5, node.rect.y + node.rect.height, Direction.Bottom))
node.anchors.push(new Point(node.rect.x, node.rect.y + (node.rect.height * 2) / 5, Direction.Left))
}
//# sourceMappingURL=pentagon.anchor.js.map
// # sourceMappingURL=pentagon.anchor.js.map

View File

@@ -1,12 +1,12 @@
export function pentagon(ctx, node) {
ctx.beginPath();
ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y);
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 5);
ctx.lineTo(node.rect.x + (node.rect.width * 4) / 5, node.rect.y + node.rect.height);
ctx.lineTo(node.rect.x + node.rect.width / 5, node.rect.y + node.rect.height);
ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 2) / 5);
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function pentagon (ctx, node) {
ctx.beginPath()
ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y)
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + (node.rect.height * 2) / 5)
ctx.lineTo(node.rect.x + (node.rect.width * 4) / 5, node.rect.y + node.rect.height)
ctx.lineTo(node.rect.x + node.rect.width / 5, node.rect.y + node.rect.height)
ctx.lineTo(node.rect.x, node.rect.y + (node.rect.height * 2) / 5)
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=pentagon.js.map
// # sourceMappingURL=pentagon.js.map

View File

@@ -1,23 +1,22 @@
import { Rect } from '../../models/rect';
export function pentagonIconRect(node) {
var w = node.rect.width / 2;
var h = node.rect.height / 2;
if (w > h) {
w = h;
}
else {
h = w;
}
var top = node.rect.height / 7;
if (top < 10) {
top = 10;
}
node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h);
import { Rect } from '../../models/rect'
export function pentagonIconRect (node) {
let w = node.rect.width / 2
let h = node.rect.height / 2
if (w > h) {
w = h
} else {
h = w
}
let top = node.rect.height / 7
if (top < 10) {
top = 10
}
node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h)
}
export function pentagonTextRect(node) {
node.textRect = new Rect(node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 5) / 7, (node.rect.width * 3) / 5, node.rect.height / 4);
var w = (node.rect.width * 3) / 5;
var h = (node.rect.height * 3) / 5;
node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 4, w, h);
export function pentagonTextRect (node) {
node.textRect = new Rect(node.rect.x + node.rect.width / 5, node.rect.y + (node.rect.height * 5) / 7, (node.rect.width * 3) / 5, node.rect.height / 4)
const w = (node.rect.width * 3) / 5
const h = (node.rect.height * 3) / 5
node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 4, w, h)
}
//# sourceMappingURL=pentagon.rect.js.map
// # sourceMappingURL=pentagon.rect.js.map

View File

@@ -1,10 +1,10 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function pentagramAnchors(node) {
node.anchors.push(new Point((Math.cos((18 / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin((18 / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Right));
node.anchors.push(new Point((Math.cos(((18 + 72) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Up));
node.anchors.push(new Point((Math.cos(((18 + 72 * 2) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 2) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Left));
node.anchors.push(new Point((Math.cos(((18 + 72 * 3) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 3) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Bottom));
node.anchors.push(new Point((Math.cos(((18 + 72 * 4) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 4) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Bottom));
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function pentagramAnchors (node) {
node.anchors.push(new Point((Math.cos((18 / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin((18 / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Right))
node.anchors.push(new Point((Math.cos(((18 + 72) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Up))
node.anchors.push(new Point((Math.cos(((18 + 72 * 2) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 2) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Left))
node.anchors.push(new Point((Math.cos(((18 + 72 * 3) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 3) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Bottom))
node.anchors.push(new Point((Math.cos(((18 + 72 * 4) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * 4) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2, Direction.Bottom))
}
//# sourceMappingURL=pentagram.anchor.js.map
// # sourceMappingURL=pentagram.anchor.js.map

View File

@@ -1,11 +1,11 @@
export function pentagram(ctx, node) {
ctx.beginPath();
for (var i = 0; i < 5; ++i) {
ctx.lineTo((Math.cos(((18 + 72 * i) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * i) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2);
ctx.lineTo((Math.cos(((54 + 72 * i) / 180) * Math.PI) * node.rect.width) / 4 + node.rect.x + node.rect.width / 2, (-Math.sin(((54 + 72 * i) / 180) * Math.PI) * node.rect.width) / 4 + node.rect.y + node.rect.height / 2);
}
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function pentagram (ctx, node) {
ctx.beginPath()
for (let i = 0; i < 5; ++i) {
ctx.lineTo((Math.cos(((18 + 72 * i) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.x + node.rect.width / 2, (-Math.sin(((18 + 72 * i) / 180) * Math.PI) * node.rect.width) / 2 + node.rect.y + node.rect.height / 2)
ctx.lineTo((Math.cos(((54 + 72 * i) / 180) * Math.PI) * node.rect.width) / 4 + node.rect.x + node.rect.width / 2, (-Math.sin(((54 + 72 * i) / 180) * Math.PI) * node.rect.width) / 4 + node.rect.y + node.rect.height / 2)
}
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=pentagram.js.map
// # sourceMappingURL=pentagram.js.map

View File

@@ -1,11 +1,11 @@
import { Rect } from '../../models/rect';
export function pentagramIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
import { Rect } from '../../models/rect'
export function pentagramIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function pentagramTextRect(node) {
var w = (node.rect.width * 2) / 5;
var h = (node.rect.height * 2) / 5;
node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h);
node.textRect = node.fullTextRect;
export function pentagramTextRect (node) {
const w = (node.rect.width * 2) / 5
const h = (node.rect.height * 2) / 5
node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + (node.rect.height - h) / 2, w, h)
node.textRect = node.fullTextRect
}
//# sourceMappingURL=pentagram.rect.js.map
// # sourceMappingURL=pentagram.rect.js.map

View File

@@ -1,17 +1,17 @@
export function people(ctx, node) {
ctx.beginPath();
var r = node.rect.width / 4;
var middle = node.rect.x + node.rect.width / 2;
ctx.arc(middle, node.rect.y + r, r, 0, Math.PI * 2);
ctx.moveTo(node.rect.x, node.rect.y + r * 3);
ctx.lineTo(node.rect.ex, node.rect.y + r * 3);
ctx.moveTo(middle, node.rect.y + r * 2);
ctx.lineTo(middle, node.rect.y + r * 4);
ctx.moveTo(middle, node.rect.y + r * 4);
ctx.lineTo(node.rect.x, node.rect.ey);
ctx.moveTo(middle, node.rect.y + r * 4);
ctx.lineTo(node.rect.ex, node.rect.ey);
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function people (ctx, node) {
ctx.beginPath()
const r = node.rect.width / 4
const middle = node.rect.x + node.rect.width / 2
ctx.arc(middle, node.rect.y + r, r, 0, Math.PI * 2)
ctx.moveTo(node.rect.x, node.rect.y + r * 3)
ctx.lineTo(node.rect.ex, node.rect.y + r * 3)
ctx.moveTo(middle, node.rect.y + r * 2)
ctx.lineTo(middle, node.rect.y + r * 4)
ctx.moveTo(middle, node.rect.y + r * 4)
ctx.lineTo(node.rect.x, node.rect.ey)
ctx.moveTo(middle, node.rect.y + r * 4)
ctx.lineTo(node.rect.ex, node.rect.ey);
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=people.js.map
// # sourceMappingURL=people.js.map

View File

@@ -1,9 +1,9 @@
import { Rect } from '../../models/rect';
export function peopleIconRect(node) {
node.iconRect = new Rect(0, 0, 0, 0);
import { Rect } from '../../models/rect'
export function peopleIconRect (node) {
node.iconRect = new Rect(0, 0, 0, 0)
}
export function peopleTextRect(node) {
node.textRect = undefined;
node.fullTextRect = node.textRect;
export function peopleTextRect (node) {
node.textRect = undefined
node.fullTextRect = node.textRect
}
//# sourceMappingURL=people.rect.js.map
// # sourceMappingURL=people.rect.js.map

View File

@@ -1,25 +1,25 @@
export function rectangle(ctx, node) {
var wr = node.borderRadius;
var hr = node.borderRadius;
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius;
hr = node.rect.height * node.borderRadius;
}
var r = wr < hr ? wr : hr;
if (node.rect.width < 2 * r) {
r = node.rect.width / 2;
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2;
}
ctx.beginPath();
ctx.moveTo(node.rect.x + r, node.rect.y);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r);
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r);
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r);
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function rectangle (ctx, node) {
let wr = node.borderRadius
let hr = node.borderRadius
if (node.borderRadius < 1) {
wr = node.rect.width * node.borderRadius
hr = node.rect.height * node.borderRadius
}
let r = wr < hr ? wr : hr
if (node.rect.width < 2 * r) {
r = node.rect.width / 2
}
if (node.rect.height < 2 * r) {
r = node.rect.height / 2
}
ctx.beginPath()
ctx.moveTo(node.rect.x + r, node.rect.y)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y, node.rect.x + node.rect.width, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r)
ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r)
ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r)
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=rectangle.js.map
// # sourceMappingURL=rectangle.js.map

View File

@@ -1,11 +1,11 @@
import { Rect } from '../../models/rect';
export function rectangleIconRect(node) {
node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum);
node.fullIconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum);
import { Rect } from '../../models/rect'
export function rectangleIconRect (node) {
node.iconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum)
node.fullIconRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, node.rect.height - node.paddingTopNum - node.paddingBottomNum)
}
export function rectangleTextRect(node) {
var height = node.rect.height - node.paddingTopNum - node.paddingBottomNum;
node.textRect = new Rect(node.rect.x + node.paddingLeftNum + height, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum - height, height);
node.fullTextRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height);
export function rectangleTextRect (node) {
const height = node.rect.height - node.paddingTopNum - node.paddingBottomNum
node.textRect = new Rect(node.rect.x + node.paddingLeftNum + height, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum - height, height)
node.fullTextRect = new Rect(node.rect.x + node.paddingLeftNum, node.rect.y + node.paddingTopNum, node.rect.width - node.paddingLeftNum - node.paddingRightNum, height)
}
//# sourceMappingURL=rectangle.rect.js.map
// # sourceMappingURL=rectangle.rect.js.map

View File

@@ -1,270 +1,263 @@
import { Store } from 'le5le-store';
import { Store } from 'le5le-store'
// getWords: Get the word array from text. A single Chinese character is a word.
export function getWords(txt) {
var words = [];
var word = '';
if (!txt) {
txt = '';
export function getWords (txt) {
const words = []
let word = ''
if (!txt) {
txt = ''
}
for (let i = 0; i < txt.length; ++i) {
const ch = txt.charCodeAt(i)
if (ch < 33 || ch > 126) {
if (word) {
words.push(word)
word = ''
}
words.push(txt[i])
continue
} else {
word += txt[i]
}
for (var i = 0; i < txt.length; ++i) {
var ch = txt.charCodeAt(i);
if (ch < 33 || ch > 126) {
if (word) {
words.push(word);
word = '';
}
words.push(txt[i]);
continue;
}
else {
word += txt[i];
}
}
if (word) {
words.push(word);
}
return words;
}
if (word) {
words.push(word)
}
return words
}
// getWrapLines: Get the lines by wrap.
// words - the word array of text, to avoid spliting a word.
// maxWidth - the max width of the rect.
export function getWrapLines(ctx, words, maxWidth, fontSize) {
var lines = [];
var currentLine = words[0] || '';
for (var i = 1; i < words.length; ++i) {
var word = words[i] || '';
var text_1 = currentLine + word;
var chinese = text_1.match(/[\u4e00-\u9fa5]/g) || '';
var chineseLen = chinese.length;
if ((text_1.length - chineseLen) * fontSize * 0.5 + chineseLen * fontSize < maxWidth) {
currentLine += word;
}
else {
lines.push(currentLine);
currentLine = word;
}
export function getWrapLines (ctx, words, maxWidth, fontSize) {
const lines = []
let currentLine = words[0] || ''
for (let i = 1; i < words.length; ++i) {
const word = words[i] || ''
const text_1 = currentLine + word
const chinese = text_1.match(/[\u4e00-\u9fa5]/g) || ''
const chineseLen = chinese.length
if ((text_1.length - chineseLen) * fontSize * 0.5 + chineseLen * fontSize < maxWidth) {
currentLine += word
} else {
lines.push(currentLine)
currentLine = word
}
lines.push(currentLine);
return lines;
}
lines.push(currentLine)
return lines
}
export function getLines(ctx, pen) {
if (pen.text && !pen.text.split) {
pen.text += '';
}
var lines = [];
switch (pen.whiteSpace) {
case 'nowrap':
lines.push(pen.text);
break;
case 'pre-line':
lines = pen.text.split(/[\n]/g);
break;
default:
var textRect = pen.getTextRect();
var paragraphs = pen.text.split(/[\n]/g);
for (var i = 0; i < paragraphs.length; ++i) {
var l = getWrapLines(ctx, getWords(paragraphs[i]), textRect.width, pen.fontSize);
lines.push.apply(lines, l);
}
break;
}
return lines;
export function getLines (ctx, pen) {
if (pen.text && !pen.text.split) {
pen.text += ''
}
let lines = []
switch (pen.whiteSpace) {
case 'nowrap':
lines.push(pen.text)
break
case 'pre-line':
lines = pen.text.split(/[\n]/g)
break
default:
var textRect = pen.getTextRect()
var paragraphs = pen.text.split(/[\n]/g)
for (let i = 0; i < paragraphs.length; ++i) {
const l = getWrapLines(ctx, getWords(paragraphs[i]), textRect.width, pen.fontSize)
lines.push.apply(lines, l)
}
break
}
return lines
}
export function calcTextRect(ctx, pen) {
var lines = getLines(ctx, pen);
var width = 0;
for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
var item = lines_1[_i];
ctx.font = (pen.fontStyle || 'normal') + " normal " + (pen.fontWeight || 'normal') + " " + pen.fontSize + "px/" + pen.lineHeight + " " + pen.fontFamily;
var r = ctx.measureText(item);
var w = r.width;
if (w > width) {
width = w;
}
export function calcTextRect (ctx, pen) {
const lines = getLines(ctx, pen)
let width = 0
for (let _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
const item = lines_1[_i]
ctx.font = (pen.fontStyle || 'normal') + ' normal ' + (pen.fontWeight || 'normal') + ' ' + pen.fontSize + 'px/' + pen.lineHeight + ' ' + pen.fontFamily
const r = ctx.measureText(item)
const w = r.width
if (w > width) {
width = w
}
return {
width: width,
height: lines.length * pen.fontSize * pen.lineHeight,
};
}
return {
width: width,
height: lines.length * pen.fontSize * pen.lineHeight
}
}
function textBk(ctx, str, x, y, height, color) {
if (!str || !color) {
return;
}
var w = ctx.measureText(str).width;
ctx.save();
ctx.fillStyle = color;
var l = x - w / 2;
var t = y - height / 2;
switch (ctx.textAlign) {
case 'left':
l = x;
break;
case 'right':
l = x - w;
break;
}
switch (ctx.textBaseline) {
case 'top':
t = y;
break;
case 'bottom':
t = y - height;
break;
}
ctx.fillRect(l, t, w, height);
ctx.restore();
function textBk (ctx, str, x, y, height, color) {
if (!str || !color) {
return
}
const w = ctx.measureText(str).width
ctx.save()
ctx.fillStyle = color
let l = x - w / 2
let t = y - height / 2
switch (ctx.textAlign) {
case 'left':
l = x
break
case 'right':
l = x - w
break
}
switch (ctx.textBaseline) {
case 'top':
t = y
break
case 'bottom':
t = y - height
break
}
ctx.fillRect(l, t, w, height)
ctx.restore()
}
export function fillText(ctx, lines, x, y, width, height, lineHeight, maxLineLen, bk) {
if (!maxLineLen || maxLineLen > lines.length) {
maxLineLen = lines.length;
export function fillText (ctx, lines, x, y, width, height, lineHeight, maxLineLen, bk) {
if (!maxLineLen || maxLineLen > lines.length) {
maxLineLen = lines.length
} else {
maxLineLen = Math.ceil(maxLineLen)
}
for (let i = 0; i < maxLineLen - 1; ++i) {
if (bk) {
textBk(ctx, lines[i], x, y + i * lineHeight, lineHeight, bk)
}
else {
maxLineLen = Math.ceil(maxLineLen);
ctx.fillText(lines[i], x, y + i * lineHeight)
}
if (maxLineLen < lines.length) {
let str = (lines[maxLineLen - 1] || '') + '...'
if (lines[maxLineLen - 1] && ctx.measureText(str).width > width) {
str = lines[maxLineLen - 1].substr(0, lines[maxLineLen - 1].length - 2) + '...'
}
for (var i = 0; i < maxLineLen - 1; ++i) {
if (bk) {
textBk(ctx, lines[i], x, y + i * lineHeight, lineHeight, bk);
}
ctx.fillText(lines[i], x, y + i * lineHeight);
if (bk) {
textBk(ctx, str, x, y + (maxLineLen - 1) * lineHeight, lineHeight, bk)
}
if (maxLineLen < lines.length) {
var str = (lines[maxLineLen - 1] || '') + '...';
if (lines[maxLineLen - 1] && ctx.measureText(str).width > width) {
str = lines[maxLineLen - 1].substr(0, lines[maxLineLen - 1].length - 2) + '...';
}
if (bk) {
textBk(ctx, str, x, y + (maxLineLen - 1) * lineHeight, lineHeight, bk);
}
ctx.fillText(str, x, y + (maxLineLen - 1) * lineHeight);
}
else {
if (bk) {
textBk(ctx, lines[maxLineLen - 1], x, y + (maxLineLen - 1) * lineHeight, lineHeight, bk);
}
ctx.fillText(lines[maxLineLen - 1], x, y + (maxLineLen - 1) * lineHeight);
ctx.fillText(str, x, y + (maxLineLen - 1) * lineHeight)
} else {
if (bk) {
textBk(ctx, lines[maxLineLen - 1], x, y + (maxLineLen - 1) * lineHeight, lineHeight, bk)
}
ctx.fillText(lines[maxLineLen - 1], x, y + (maxLineLen - 1) * lineHeight)
}
}
export function text(ctx, node) {
if (!node.text) {
return;
}
if (!node.text.split) {
node.text += '';
}
ctx.save();
ctx.beginPath();
delete ctx.shadowColor;
delete ctx.shadowBlur;
ctx.font = (node.fontStyle || 'normal') + " normal " + (node.fontWeight || 'normal') + " " + node.fontSize + "px/" + node.lineHeight + " " + node.fontFamily;
if (node.fontColor) {
ctx.fillStyle = node.fontColor;
}
else {
ctx.fillStyle = Store.get(node.generateStoreKey('LT:fontColor'));
}
if (node.textAlign) {
ctx.textAlign = node.textAlign;
}
if (node.textBaseline) {
ctx.textBaseline = node.textBaseline;
}
var textRect = node.getTextRect();
if (!textRect) {
ctx.restore();
return;
}
var lines = getLines(ctx, node);
var lineHeight = node.fontSize * node.lineHeight;
var maxLineLen = node.textMaxLine > 0 && node.textMaxLine < lines.length ? node.textMaxLine : lines.length;
// By default, the text is center aligned.
var x = textRect.x + textRect.width / 2;
var y = textRect.y + (textRect.height - lineHeight * maxLineLen) / 2 + (lineHeight * 4) / 7;
switch (ctx.textAlign) {
case 'left':
x = textRect.x;
break;
case 'right':
x = textRect.x + textRect.width;
break;
}
switch (ctx.textBaseline) {
case 'top':
y = textRect.y + (lineHeight - node.fontSize) / 2;
break;
case 'bottom':
y = textRect.ey - lineHeight * maxLineLen + lineHeight;
break;
}
fillText(ctx, lines, x + node.textOffsetX, y + node.textOffsetY, textRect.width, textRect.height, lineHeight, maxLineLen, node.textBackground);
ctx.restore();
export function text (ctx, node) {
if (!node.text) {
return
}
if (!node.text.split) {
node.text += ''
}
ctx.save()
ctx.beginPath()
delete ctx.shadowColor
delete ctx.shadowBlur
ctx.font = (node.fontStyle || 'normal') + ' normal ' + (node.fontWeight || 'normal') + ' ' + node.fontSize + 'px/' + node.lineHeight + ' ' + node.fontFamily
if (node.fontColor) {
ctx.fillStyle = node.fontColor
} else {
ctx.fillStyle = Store.get(node.generateStoreKey('LT:fontColor'))
}
if (node.textAlign) {
ctx.textAlign = node.textAlign
}
if (node.textBaseline) {
ctx.textBaseline = node.textBaseline
}
const textRect = node.getTextRect()
if (!textRect) {
ctx.restore()
return
}
const lines = getLines(ctx, node)
const lineHeight = node.fontSize * node.lineHeight
const maxLineLen = node.textMaxLine > 0 && node.textMaxLine < lines.length ? node.textMaxLine : lines.length
// By default, the text is center aligned.
let x = textRect.x + textRect.width / 2
let y = textRect.y + (textRect.height - lineHeight * maxLineLen) / 2 + (lineHeight * 4) / 7
switch (ctx.textAlign) {
case 'left':
x = textRect.x
break
case 'right':
x = textRect.x + textRect.width
break
}
switch (ctx.textBaseline) {
case 'top':
y = textRect.y + (lineHeight - node.fontSize) / 2
break
case 'bottom':
y = textRect.ey - lineHeight * maxLineLen + lineHeight
break
}
fillText(ctx, lines, x + node.textOffsetX, y + node.textOffsetY, textRect.width, textRect.height, lineHeight, maxLineLen, node.textBackground)
ctx.restore()
}
export function iconfont(ctx, node) {
ctx.save();
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
var iconRect = node.getIconRect();
var x = iconRect.x + iconRect.width / 2;
var y = iconRect.y + iconRect.height / 2;
switch (node.imageAlign) {
case 'top':
y = iconRect.y;
ctx.textBaseline = 'top';
break;
case 'bottom':
y = iconRect.ey;
ctx.textBaseline = 'bottom';
break;
case 'left':
x = iconRect.x;
ctx.textAlign = 'left';
break;
case 'right':
x = iconRect.ex;
ctx.textAlign = 'right';
break;
case 'left-top':
x = iconRect.x;
y = iconRect.y;
ctx.textAlign = 'left';
ctx.textBaseline = 'top';
break;
case 'right-top':
x = iconRect.ex;
y = iconRect.y;
ctx.textAlign = 'right';
ctx.textBaseline = 'top';
break;
case 'left-bottom':
x = iconRect.x;
y = iconRect.ey;
ctx.textAlign = 'left';
ctx.textBaseline = 'bottom';
break;
case 'right-bottom':
x = iconRect.ex;
y = iconRect.ey;
ctx.textAlign = 'right';
ctx.textBaseline = 'bottom';
break;
}
if (node.iconSize > 0) {
ctx.font = node.iconSize + "px " + node.iconFamily;
}
else if (iconRect.width > iconRect.height) {
ctx.font = iconRect.height + "px " + node.iconFamily;
}
else {
ctx.font = iconRect.width + "px " + node.iconFamily;
}
ctx.fillStyle = node.iconColor || Store.get(node.generateStoreKey('LT:iconColor')) || node.fontColor;
if (node.iconRotate) {
ctx.translate(iconRect.center.x, iconRect.center.y);
ctx.rotate((node.iconRotate * Math.PI) / 180);
ctx.translate(-iconRect.center.x, -iconRect.center.y);
}
ctx.beginPath();
ctx.fillText(node.icon, x, y);
ctx.restore();
export function iconfont (ctx, node) {
ctx.save()
ctx.textAlign = 'center'
ctx.textBaseline = 'middle'
const iconRect = node.getIconRect()
let x = iconRect.x + iconRect.width / 2
let y = iconRect.y + iconRect.height / 2
switch (node.imageAlign) {
case 'top':
y = iconRect.y
ctx.textBaseline = 'top'
break
case 'bottom':
y = iconRect.ey
ctx.textBaseline = 'bottom'
break
case 'left':
x = iconRect.x
ctx.textAlign = 'left'
break
case 'right':
x = iconRect.ex
ctx.textAlign = 'right'
break
case 'left-top':
x = iconRect.x
y = iconRect.y
ctx.textAlign = 'left'
ctx.textBaseline = 'top'
break
case 'right-top':
x = iconRect.ex
y = iconRect.y
ctx.textAlign = 'right'
ctx.textBaseline = 'top'
break
case 'left-bottom':
x = iconRect.x
y = iconRect.ey
ctx.textAlign = 'left'
ctx.textBaseline = 'bottom'
break
case 'right-bottom':
x = iconRect.ex
y = iconRect.ey
ctx.textAlign = 'right'
ctx.textBaseline = 'bottom'
break
}
if (node.iconSize > 0) {
ctx.font = node.iconSize + 'px ' + node.iconFamily
} else if (iconRect.width > iconRect.height) {
ctx.font = iconRect.height + 'px ' + node.iconFamily
} else {
ctx.font = iconRect.width + 'px ' + node.iconFamily
}
ctx.fillStyle = node.iconColor || Store.get(node.generateStoreKey('LT:iconColor')) || node.fontColor
if (node.iconRotate) {
ctx.translate(iconRect.center.x, iconRect.center.y)
ctx.rotate((node.iconRotate * Math.PI) / 180)
ctx.translate(-iconRect.center.x, -iconRect.center.y)
}
ctx.beginPath()
ctx.fillText(node.icon, x, y)
ctx.restore()
}
//# sourceMappingURL=text.js.map
// # sourceMappingURL=text.js.map

View File

@@ -1,9 +1,9 @@
import { Point } from '../../models/point';
import { Direction } from '../../models/direction';
export function triangleAnchors(node) {
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up));
node.anchors.push(new Point(node.rect.x + (node.rect.width * 3) / 4, node.rect.y + node.rect.height / 2, Direction.Right));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom));
node.anchors.push(new Point(node.rect.x + node.rect.width / 4, node.rect.y + node.rect.height / 2, Direction.Left));
import { Point } from '../../models/point'
import { Direction } from '../../models/direction'
export function triangleAnchors (node) {
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up))
node.anchors.push(new Point(node.rect.x + (node.rect.width * 3) / 4, node.rect.y + node.rect.height / 2, Direction.Right))
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom))
node.anchors.push(new Point(node.rect.x + node.rect.width / 4, node.rect.y + node.rect.height / 2, Direction.Left))
}
//# sourceMappingURL=triangle.anchor.js.map
// # sourceMappingURL=triangle.anchor.js.map

View File

@@ -1,10 +1,10 @@
export function triangle(ctx, node) {
ctx.beginPath();
ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y);
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height);
ctx.lineTo(node.rect.x, node.rect.y + node.rect.height);
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill();
ctx.stroke();
export function triangle (ctx, node) {
ctx.beginPath()
ctx.moveTo(node.rect.x + node.rect.width / 2, node.rect.y)
ctx.lineTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height)
ctx.lineTo(node.rect.x, node.rect.y + node.rect.height)
ctx.closePath();
(node.fillStyle || node.bkType) && ctx.fill()
ctx.stroke()
}
//# sourceMappingURL=triangle.js.map
// # sourceMappingURL=triangle.js.map

View File

@@ -1,23 +1,22 @@
import { Rect } from '../../models/rect';
export function triangleIconRect(node) {
var w = (node.rect.width * 2) / 7;
var h = (node.rect.height * 2) / 7;
if (w > h) {
w = h;
}
else {
h = w;
}
var top = w;
if (top < 10) {
top = 10;
}
node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h);
import { Rect } from '../../models/rect'
export function triangleIconRect (node) {
let w = (node.rect.width * 2) / 7
let h = (node.rect.height * 2) / 7
if (w > h) {
w = h
} else {
h = w
}
let top = w
if (top < 10) {
top = 10
}
node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h)
}
export function triangleTextRect(node) {
node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + (node.rect.height * 2) / 3, node.rect.width / 2, node.rect.height / 3 - 5);
var w = node.rect.width / 2;
var h = (node.rect.height * 3) / 7;
node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 2 - 5, w, h);
export function triangleTextRect (node) {
node.textRect = new Rect(node.rect.x + node.rect.width / 4, node.rect.y + (node.rect.height * 2) / 3, node.rect.width / 2, node.rect.height / 3 - 5)
const w = node.rect.width / 2
const h = (node.rect.height * 3) / 7
node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 2 - 5, w, h)
}
//# sourceMappingURL=triangle.rect.js.map
// # sourceMappingURL=triangle.rect.js.map

View File

@@ -1,67 +1,64 @@
import { Node } from './node';
import { Line } from './line';
import { Lock } from './status';
import { s8 } from '../utils';
import { Store } from 'le5le-store';
import { Rect } from './rect';
export function createData(json, tid) {
var data = {
pens: [],
lineName: 'curve',
fromArrow: '',
toArrow: 'triangleSolid',
scale: 1,
locked: Lock.None,
x: 0,
y: 0,
};
if (typeof json === 'string') {
json = JSON.parse(json);
import { Node } from './node'
import { Line } from './line'
import { Lock } from './status'
import { s8 } from '../utils'
import { Store } from 'le5le-store'
import { Rect } from './rect'
export function createData (json, tid) {
let data = {
pens: [],
lineName: 'curve',
fromArrow: '',
toArrow: 'triangleSolid',
scale: 1,
locked: Lock.None,
x: 0,
y: 0
}
if (typeof json === 'string') {
json = JSON.parse(json)
}
data = Object.assign(data, json)
data.pens = []
if (json) {
// for old data.
if (json.nodes) {
for (let _i = 0, _a = json.nodes; _i < _a.length; _i++) {
var item = _a[_i]
item.TID = tid
data.pens.push(new Node(item))
}
for (let _b = 0, _c = json.lines; _b < _c.length; _b++) {
var item = _c[_b]
item.TID = tid
data.pens.push(new Line(item))
}
}
data = Object.assign(data, json);
data.pens = [];
if (json) {
// for old data.
if (json.nodes) {
for (var _i = 0, _a = json.nodes; _i < _a.length; _i++) {
var item = _a[_i];
item.TID = tid;
data.pens.push(new Node(item));
}
for (var _b = 0, _c = json.lines; _b < _c.length; _b++) {
var item = _c[_b];
item.TID = tid;
data.pens.push(new Line(item));
}
}
// end.
json.pens && json.pens.forEach(function (item) {
tid && (item.TID = tid);
if (!item.type) {
data.pens.push(new Node(item));
}
else {
data.pens.push(new Line(item));
}
});
if (json.bkImageRect) {
data.bkImageRect = new Rect(json.bkImageRect.x, json.bkImageRect.y, json.bkImageRect.width, json.bkImageRect.height);
}
// end.
json.pens && json.pens.forEach(function (item) {
tid && (item.TID = tid)
if (!item.type) {
data.pens.push(new Node(item))
} else {
data.pens.push(new Line(item))
}
})
if (json.bkImageRect) {
data.bkImageRect = new Rect(json.bkImageRect.x, json.bkImageRect.y, json.bkImageRect.width, json.bkImageRect.height)
}
if (data.mqttOptions) {
var opts = '';
if (typeof data.mqttOptions === 'object') {
opts = JSON.stringify(data.mqttOptions);
}
else {
opts = data.mqttOptions + '';
}
data.mqttOptions = JSON.parse(opts);
}
if (data.mqttOptions) {
let opts = ''
if (typeof data.mqttOptions === 'object') {
opts = JSON.stringify(data.mqttOptions)
} else {
opts = data.mqttOptions + ''
}
else {
data.mqttOptions = { clientId: s8() };
}
tid && Store.set(tid + '-topology-data', data);
return data;
data.mqttOptions = JSON.parse(opts)
} else {
data.mqttOptions = { clientId: s8() }
}
tid && Store.set(tid + '-topology-data', data)
return data
}
//# sourceMappingURL=data.js.map
// # sourceMappingURL=data.js.map

View File

@@ -1,9 +1,9 @@
export var Direction;
(function (Direction) {
Direction[Direction["None"] = 0] = "None";
Direction[Direction["Up"] = 1] = "Up";
Direction[Direction["Right"] = 2] = "Right";
Direction[Direction["Bottom"] = 3] = "Bottom";
Direction[Direction["Left"] = 4] = "Left";
})(Direction || (Direction = {}));
//# sourceMappingURL=direction.js.map
Direction[Direction.None = 0] = 'None'
Direction[Direction.Up = 1] = 'Up'
Direction[Direction.Right = 2] = 'Right'
Direction[Direction.Bottom = 3] = 'Bottom'
Direction[Direction.Left = 4] = 'Left'
})(Direction || (Direction = {}))
// # sourceMappingURL=direction.js.map

View File

@@ -1,21 +1,21 @@
export var EventType;
(function (EventType) {
EventType[EventType["Click"] = 0] = "Click";
EventType[EventType["DblClick"] = 1] = "DblClick";
EventType[EventType["WebSocket"] = 2] = "WebSocket";
EventType[EventType["Mqtt"] = 3] = "Mqtt";
EventType[EventType["MoveIn"] = 4] = "MoveIn";
EventType[EventType["MoveOut"] = 5] = "MoveOut";
})(EventType || (EventType = {}));
EventType[EventType.Click = 0] = 'Click'
EventType[EventType.DblClick = 1] = 'DblClick'
EventType[EventType.WebSocket = 2] = 'WebSocket'
EventType[EventType.Mqtt = 3] = 'Mqtt'
EventType[EventType.MoveIn = 4] = 'MoveIn'
EventType[EventType.MoveOut = 5] = 'MoveOut'
})(EventType || (EventType = {}))
export var EventAction;
(function (EventAction) {
EventAction[EventAction["Link"] = 0] = "Link";
EventAction[EventAction["StartAnimate"] = 1] = "StartAnimate";
EventAction[EventAction["Function"] = 2] = "Function";
EventAction[EventAction["WindowFn"] = 3] = "WindowFn";
EventAction[EventAction["SetProps"] = 4] = "SetProps";
EventAction[EventAction["PauseAnimate"] = 5] = "PauseAnimate";
EventAction[EventAction["StopAnimate"] = 6] = "StopAnimate";
EventAction[EventAction["Emit"] = 7] = "Emit";
})(EventAction || (EventAction = {}));
//# sourceMappingURL=event.js.map
EventAction[EventAction.Link = 0] = 'Link'
EventAction[EventAction.StartAnimate = 1] = 'StartAnimate'
EventAction[EventAction.Function = 2] = 'Function'
EventAction[EventAction.WindowFn = 3] = 'WindowFn'
EventAction[EventAction.SetProps = 4] = 'SetProps'
EventAction[EventAction.PauseAnimate = 5] = 'PauseAnimate'
EventAction[EventAction.StopAnimate = 6] = 'StopAnimate'
EventAction[EventAction.Emit = 7] = 'Emit'
})(EventAction || (EventAction = {}))
// # sourceMappingURL=event.js.map

View File

@@ -1,10 +1,10 @@
export * from './data';
export * from './pen';
export * from './node';
export * from './line';
export * from './direction';
export * from './point';
export * from './rect';
export * from './status';
export * from './event';
//# sourceMappingURL=index.js.map
export * from './data'
export * from './pen'
export * from './node'
export * from './line'
export * from './direction'
export * from './point'
export * from './rect'
export * from './status'
export * from './event'
// # sourceMappingURL=index.js.map

Some files were not shown because too many files have changed in this diff Show More