vislite 1.2.0-alpha.7 → 1.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG +2 -0
- package/README.md +2 -1
- package/lib/Buffer/index.es.js +1 -1
- package/lib/Buffer/index.es.min.js +1 -1
- package/lib/Canvas/index.es.js +47 -21
- package/lib/Canvas/index.es.min.js +2 -2
- package/lib/Cardinal/index.es.js +1 -1
- package/lib/Cardinal/index.es.min.js +1 -1
- package/lib/Eoap/index.es.js +1 -1
- package/lib/Eoap/index.es.min.js +1 -1
- package/lib/Hermite/index.es.js +1 -1
- package/lib/Hermite/index.es.min.js +1 -1
- package/lib/Matrix4/index.es.js +1 -1
- package/lib/Matrix4/index.es.min.js +1 -1
- package/lib/Mercator/index.es.js +1 -1
- package/lib/Mercator/index.es.min.js +1 -1
- package/lib/RawCanvas/index.es.js +47 -21
- package/lib/RawCanvas/index.es.min.js +2 -2
- package/lib/SVG/index.es.js +23 -15
- package/lib/SVG/index.es.min.js +2 -2
- package/lib/Shader/index.es.js +1 -1
- package/lib/Shader/index.es.min.js +1 -1
- package/lib/Texture/index.es.js +1 -1
- package/lib/Texture/index.es.min.js +1 -1
- package/lib/TreeLayout/index.es.js +1 -1
- package/lib/TreeLayout/index.es.min.js +1 -1
- package/lib/animation/index.es.js +1 -1
- package/lib/animation/index.es.min.js +1 -1
- package/lib/assemble/index.es.js +1 -1
- package/lib/assemble/index.es.min.js +1 -1
- package/lib/getLoopColors/index.es.js +1 -1
- package/lib/getLoopColors/index.es.min.js +1 -1
- package/lib/getWebGLContext/index.es.js +1 -1
- package/lib/getWebGLContext/index.es.min.js +1 -1
- package/lib/index.umd.js +69 -35
- package/lib/index.umd.min.js +2 -2
- package/lib/initOption/index.es.js +1 -1
- package/lib/initOption/index.es.min.js +1 -1
- package/lib/mergeOption/index.es.js +1 -1
- package/lib/mergeOption/index.es.min.js +1 -1
- package/lib/move/index.es.js +1 -1
- package/lib/move/index.es.min.js +1 -1
- package/lib/rotate/index.es.js +1 -1
- package/lib/rotate/index.es.min.js +1 -1
- package/lib/ruler/index.es.js +1 -1
- package/lib/ruler/index.es.min.js +1 -1
- package/lib/scale/index.es.js +1 -1
- package/lib/scale/index.es.min.js +1 -1
- package/lib/throttle/index.es.js +1 -1
- package/lib/throttle/index.es.min.js +1 -1
- package/package.json +1 -1
- package/src/common/canvas/default.ts +62 -0
- package/src/common/canvas/index.ts +13 -7
- package/src/common/canvas/painter.ts +3 -54
- package/src/common/svg/default.ts +27 -0
- package/src/common/svg/index.ts +8 -26
- package/types/Canvas.d.ts +5 -0
- package/types/SVG.d.ts +5 -0
package/package.json
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { arcCapType } from '../../../types/painterConfig'
|
|
2
|
+
|
|
3
|
+
export default function (type?: string) {
|
|
4
|
+
|
|
5
|
+
let special = {
|
|
6
|
+
// 文字大小
|
|
7
|
+
"fontSize": 16,
|
|
8
|
+
|
|
9
|
+
// 字体
|
|
10
|
+
"fontFamily": "sans-serif",
|
|
11
|
+
|
|
12
|
+
// 字重
|
|
13
|
+
"fontWeight": 400,
|
|
14
|
+
|
|
15
|
+
// 字类型
|
|
16
|
+
"fontStyle": "normal",
|
|
17
|
+
|
|
18
|
+
// 圆弧开始端闭合方式("butt"直线闭合、"round"圆帽闭合)
|
|
19
|
+
"arcStartCap": <arcCapType>'butt',
|
|
20
|
+
|
|
21
|
+
// 圆弧结束端闭合方式,和上一个类似
|
|
22
|
+
"arcEndCap": <arcCapType>'butt'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let init = {
|
|
26
|
+
// 填充色或图案
|
|
27
|
+
"fillStyle": 'black',
|
|
28
|
+
|
|
29
|
+
// 轮廓色或图案
|
|
30
|
+
"strokeStyle": 'black',
|
|
31
|
+
|
|
32
|
+
// 线条宽度(单位px,下同)
|
|
33
|
+
"lineWidth": 1,
|
|
34
|
+
|
|
35
|
+
// 线的端点类型,("butt"平直边缘、"round"半圆和"square"矩形)
|
|
36
|
+
"lineCap": "butt",
|
|
37
|
+
|
|
38
|
+
// 线的拐角连接方式,("miter"连接处边缘延长相接、"bevel"对角线斜角和"round"圆)
|
|
39
|
+
"lineJoin": "miter",
|
|
40
|
+
|
|
41
|
+
// 设置线条虚线,应该是一个数组[number,...]
|
|
42
|
+
"lineDash": [],
|
|
43
|
+
|
|
44
|
+
// 文字水平对齐方式("left"左对齐、"center"居中和"right"右对齐)
|
|
45
|
+
"textAlign": 'left',
|
|
46
|
+
|
|
47
|
+
// 文字垂直对齐方式("middle"垂直居中、"top"上对齐和"bottom"下对齐)
|
|
48
|
+
"textBaseline": 'middle',
|
|
49
|
+
|
|
50
|
+
// 阴影的模糊系数,默认0,也就是无阴影
|
|
51
|
+
"shadowBlur": 0,
|
|
52
|
+
|
|
53
|
+
// 阴影的颜色
|
|
54
|
+
"shadowColor": "black"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (type == 'special') return special
|
|
58
|
+
else if (type == 'init') return init
|
|
59
|
+
else return {
|
|
60
|
+
...special, ...init
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -5,6 +5,7 @@ import PainterRender from "./painter"
|
|
|
5
5
|
import assemble from "../assemble"
|
|
6
6
|
import { linearGradient, radialGradient, conicGradient } from "./gradient"
|
|
7
7
|
import { initText } from './config'
|
|
8
|
+
import defaultFactory from "./default"
|
|
8
9
|
|
|
9
10
|
class Canvas extends PainterRender {
|
|
10
11
|
readonly name: string = "Canvas"
|
|
@@ -33,12 +34,17 @@ class Canvas extends PainterRender {
|
|
|
33
34
|
|
|
34
35
|
config(configs: CanvasConfigType) {
|
|
35
36
|
for (const key in configs) {
|
|
36
|
-
this.useConfig(key, configs[key])
|
|
37
|
+
this.useConfig(key, (configs as any)[key])
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
return this
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
reset() {
|
|
44
|
+
this.config(defaultFactory() as CanvasConfigType)
|
|
45
|
+
return this
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
// 是否绘制的内容只需要进行区域记录
|
|
43
49
|
onlyRegion(flag: boolean) {
|
|
44
50
|
this.__onlyRegion = flag
|
|
@@ -54,14 +60,14 @@ class Canvas extends PainterRender {
|
|
|
54
60
|
setRegion(regionName: string | number) {
|
|
55
61
|
if (this.__region) {
|
|
56
62
|
if (regionName) {
|
|
57
|
-
if (this.__regionList[regionName] == void 0) {
|
|
58
|
-
const tempColor = this.__regionAssemble()
|
|
59
|
-
this.__regionList[regionName] =
|
|
63
|
+
if ((this.__regionList as any)[regionName] == void 0) {
|
|
64
|
+
const tempColor = this.__regionAssemble();
|
|
65
|
+
(this.__regionList as any)[regionName] =
|
|
60
66
|
"rgb(" + tempColor[0] + "," + tempColor[1] + "," + tempColor[2] + ")"
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
this.__region.useConfig("fillStyle", this.__regionList[regionName]) &&
|
|
64
|
-
this.__region.useConfig("strokeStyle", this.__regionList[regionName])
|
|
69
|
+
this.__region.useConfig("fillStyle", (this.__regionList as any)[regionName]) &&
|
|
70
|
+
this.__region.useConfig("strokeStyle", (this.__regionList as any)[regionName])
|
|
65
71
|
} else {
|
|
66
72
|
this.__region.useConfig("fillStyle", "#000000") &&
|
|
67
73
|
this.__region.useConfig("strokeStyle", "#000000")
|
|
@@ -93,7 +99,7 @@ class Canvas extends PainterRender {
|
|
|
93
99
|
"," +
|
|
94
100
|
currentRGBA[2] +
|
|
95
101
|
")" ==
|
|
96
|
-
this.__regionList[key]
|
|
102
|
+
(this.__regionList as any)[key]
|
|
97
103
|
) {
|
|
98
104
|
resolve(key)
|
|
99
105
|
break
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { arcCapType } from '../../../types/painterConfig'
|
|
2
1
|
import type CanvasOptsType from '../../../types/CanvasOpts'
|
|
3
2
|
|
|
4
3
|
import { initText, initArc, initCircle, initRect } from './config'
|
|
5
4
|
import texts from './texts'
|
|
5
|
+
import defaultFactory from "./default"
|
|
6
6
|
|
|
7
7
|
class Painter {
|
|
8
8
|
|
|
@@ -16,62 +16,11 @@ class Painter {
|
|
|
16
16
|
|
|
17
17
|
// 用于记录配置
|
|
18
18
|
// 因为部分配置的设置比较特殊,只先记录意图
|
|
19
|
-
__specialConfig = {
|
|
20
|
-
|
|
21
|
-
// 文字大小
|
|
22
|
-
"fontSize": 16,
|
|
23
|
-
|
|
24
|
-
// 字体
|
|
25
|
-
"fontFamily": "sans-serif",
|
|
26
|
-
|
|
27
|
-
// 字重
|
|
28
|
-
"fontWeight": 400,
|
|
29
|
-
|
|
30
|
-
// 字类型
|
|
31
|
-
"fontStyle": "normal",
|
|
32
|
-
|
|
33
|
-
// 圆弧开始端闭合方式("butt"直线闭合、"round"圆帽闭合)
|
|
34
|
-
"arcStartCap": <arcCapType>'butt',
|
|
35
|
-
|
|
36
|
-
// 圆弧结束端闭合方式,和上一个类似
|
|
37
|
-
"arcEndCap": <arcCapType>'butt'
|
|
38
|
-
} as {
|
|
19
|
+
__specialConfig = defaultFactory("special") as {
|
|
39
20
|
[key: string]: any
|
|
40
21
|
}
|
|
41
22
|
|
|
42
|
-
private __initConfig =
|
|
43
|
-
|
|
44
|
-
// 填充色或图案
|
|
45
|
-
"fillStyle": 'black',
|
|
46
|
-
|
|
47
|
-
// 轮廓色或图案
|
|
48
|
-
"strokeStyle": 'black',
|
|
49
|
-
|
|
50
|
-
// 线条宽度(单位px,下同)
|
|
51
|
-
"lineWidth": 1,
|
|
52
|
-
|
|
53
|
-
// 线的端点类型,("butt"平直边缘、"round"半圆和"square"矩形)
|
|
54
|
-
"lineCap": "butt",
|
|
55
|
-
|
|
56
|
-
// 线的拐角连接方式,("miter"连接处边缘延长相接、"bevel"对角线斜角和"round"圆)
|
|
57
|
-
"lineJoin": "miter",
|
|
58
|
-
|
|
59
|
-
// 设置线条虚线,应该是一个数组[number,...]
|
|
60
|
-
"lineDash": [],
|
|
61
|
-
|
|
62
|
-
// 文字水平对齐方式("left"左对齐、"center"居中和"right"右对齐)
|
|
63
|
-
"textAlign": 'left',
|
|
64
|
-
|
|
65
|
-
// 文字垂直对齐方式("middle"垂直居中、"top"上对齐和"bottom"下对齐)
|
|
66
|
-
"textBaseline": 'middle',
|
|
67
|
-
|
|
68
|
-
// 阴影的模糊系数,默认0,也就是无阴影
|
|
69
|
-
"shadowBlur": 0,
|
|
70
|
-
|
|
71
|
-
// 阴影的颜色
|
|
72
|
-
"shadowColor": "black"
|
|
73
|
-
|
|
74
|
-
}
|
|
23
|
+
private __initConfig = defaultFactory("init")
|
|
75
24
|
|
|
76
25
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
77
26
|
constructor(canvas: HTMLCanvasElement, opts: CanvasOptsType = {}, region?: Painter, isPainter = false, scaleSize = 1) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { arcCapType, textAlignType, textBaselineType, lineCapType, lineJoinType } from "../../../types/painterConfig"
|
|
2
|
+
|
|
3
|
+
export default function () {
|
|
4
|
+
return {
|
|
5
|
+
// 颜色
|
|
6
|
+
fillStyle: "#000",
|
|
7
|
+
strokeStyle: "#000",
|
|
8
|
+
|
|
9
|
+
// 文字对齐方式
|
|
10
|
+
textAlign: <textAlignType>"left",
|
|
11
|
+
textBaseline: <textBaselineType>"middle",
|
|
12
|
+
|
|
13
|
+
// 文字
|
|
14
|
+
"fontSize": 16,
|
|
15
|
+
"fontFamily": "sans-serif",
|
|
16
|
+
|
|
17
|
+
// arc二端闭合方式['butt':直线闭合,'round':圆帽闭合]
|
|
18
|
+
"arcStartCap": <arcCapType>"butt",
|
|
19
|
+
"arcEndCap": <arcCapType>"butt",
|
|
20
|
+
|
|
21
|
+
// 线条
|
|
22
|
+
lineDash: [],
|
|
23
|
+
lineWidth: 1,
|
|
24
|
+
lineCap: <lineCapType>"butt",
|
|
25
|
+
lineJoin: <lineJoinType>"miter"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/common/svg/index.ts
CHANGED
|
@@ -1,39 +1,16 @@
|
|
|
1
1
|
import type { default as SVGConfigType, svgElType, svgBoardType } from "../../../types/SVGConfig"
|
|
2
|
-
import type { arcCapType, textAlignType, textBaselineType, lineCapType, lineJoinType } from "../../../types/painterConfig"
|
|
3
2
|
|
|
4
3
|
import { initText, initCircle, initPath, initRect, initArc } from "./config"
|
|
5
4
|
import { toNode, setAttribute, getAttribute, full, fill, stroke } from "./tool"
|
|
6
5
|
import rotate from "../../rotate"
|
|
7
6
|
import { linearGradient, radialGradient } from "./gradient"
|
|
7
|
+
import defaultFactory from "./default"
|
|
8
8
|
|
|
9
9
|
class SVG {
|
|
10
10
|
readonly name: string = "SVG"
|
|
11
11
|
|
|
12
12
|
// 用于记录配置
|
|
13
|
-
private __config =
|
|
14
|
-
|
|
15
|
-
// 颜色
|
|
16
|
-
fillStyle: "#000",
|
|
17
|
-
strokeStyle: "#000",
|
|
18
|
-
|
|
19
|
-
// 文字对齐方式
|
|
20
|
-
textAlign: <textAlignType>"left",
|
|
21
|
-
textBaseline: <textBaselineType>"middle",
|
|
22
|
-
|
|
23
|
-
// 文字
|
|
24
|
-
"fontSize": 16,
|
|
25
|
-
"fontFamily": "sans-serif",
|
|
26
|
-
|
|
27
|
-
// arc二端闭合方式['butt':直线闭合,'round':圆帽闭合]
|
|
28
|
-
"arcStartCap": <arcCapType>"butt",
|
|
29
|
-
"arcEndCap": <arcCapType>"butt",
|
|
30
|
-
|
|
31
|
-
// 线条
|
|
32
|
-
lineDash: [],
|
|
33
|
-
lineWidth: 1,
|
|
34
|
-
lineCap: <lineCapType>"butt",
|
|
35
|
-
lineJoin: <lineJoinType>"miter"
|
|
36
|
-
}
|
|
13
|
+
private __config = defaultFactory()
|
|
37
14
|
|
|
38
15
|
// 作用的节点
|
|
39
16
|
private __useEl: SVGElement
|
|
@@ -53,12 +30,17 @@ class SVG {
|
|
|
53
30
|
return this.__config[params]
|
|
54
31
|
} else {
|
|
55
32
|
for (const key in params) {
|
|
56
|
-
this.__config[key] = params[key]
|
|
33
|
+
(this.__config as any)[key] = (params as any)[key]
|
|
57
34
|
}
|
|
58
35
|
}
|
|
59
36
|
return this
|
|
60
37
|
}
|
|
61
38
|
|
|
39
|
+
reset() {
|
|
40
|
+
this.config(defaultFactory())
|
|
41
|
+
return this
|
|
42
|
+
}
|
|
43
|
+
|
|
62
44
|
/**
|
|
63
45
|
* 基础方法
|
|
64
46
|
* ---------------------------------
|
package/types/Canvas.d.ts
CHANGED