kfb-view 2.2.1 → 2.2.4

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/src/tool/Brush.js CHANGED
@@ -46,6 +46,12 @@ class Brush {
46
46
  this.thumb.draw(point, config);
47
47
  }
48
48
 
49
+ drawPoints(points, config) {
50
+ points.forEach((point) => {
51
+ this.drawThumb(point, config);
52
+ });
53
+ }
54
+
49
55
  /**
50
56
  * 画笔具体操作
51
57
  * @param {Object[]} points - 绘制的点
@@ -62,27 +68,26 @@ class Brush {
62
68
  * @param {number} [scale=1]
63
69
  */
64
70
  drawMeasureInfo(label, info, scale = 1) {
65
- const {left, top, content, angle} = info;
71
+ const {left, top, texts, angle} = info;
66
72
  const ctx = this.canvas.getContext('2d');
67
73
  ctx.save();
68
74
  ctx.beginPath();
69
75
  ctx.translate(left, top);
70
76
  ctx.rotate(angle);
71
77
  ctx.scale(scale, scale);
72
- ctx.font = `14px Arial`;
73
78
  const widthList = [];
74
- content.forEach((info) => {
79
+ ctx.font = `${this.options.measure.fontSize}px Arial`;
80
+ texts.forEach((info) => {
75
81
  widthList.push(ctx.measureText(info).width);
76
82
  });
77
83
  const width = Math.max(...widthList);
78
- ctx.fillStyle = 'rgba(0,0,0,.5)';
79
- const height = content.length * 20 + 16 + (content.length - 1) * 4;
84
+ ctx.fillStyle = this.options.measure.backgroundColor;
85
+ const height = texts.length * 20 + 16 + (texts.length - 1) * 4;
80
86
  ctx.rect(0, 0, width + 22, height);
81
87
  ctx.fill();
82
88
  ctx.beginPath();
83
- ctx.font = `14px Arial`;
84
- ctx.fillStyle = '#FDFDFD';
85
- content.forEach((info, index) => {
89
+ ctx.fillStyle = this.options.measure.color;
90
+ texts.forEach((info, index) => {
86
91
  ctx.fillText(info, 11, 8 + 14 + index * 24);
87
92
  });
88
93
  ctx.fill();
@@ -27,12 +27,6 @@ class Polygon extends Brush {
27
27
  }
28
28
  }
29
29
  }
30
-
31
- drawPoints(points, config) {
32
- points.forEach((point) => {
33
- this.drawThumb(point, config);
34
- });
35
- }
36
30
  }
37
31
 
38
32
  export {
package/src/view.js CHANGED
@@ -19,6 +19,7 @@ export default class KfbView extends EventEmitter {
19
19
  * @constructs
20
20
  * @param {Object} config 配置参数
21
21
  * @param {HTMLElement|string} config.el 图像容器
22
+ * @param {number=} config.scale 图像的最大倍率
22
23
  * @param {Object} config.openSeadragonOptions openSeadragon参数
23
24
  * @param {function=} config.tileDrawing openSeadragon绘制tile-drawing事件回调
24
25
  * @param {Object} [config.navigator = {}] navigator参数
@@ -27,10 +28,11 @@ export default class KfbView extends EventEmitter {
27
28
  * @param {string} config.navigator.width navigator宽度
28
29
  * @param {string} config.navigator.height navigator高度
29
30
  * @param {string} config.navigator.thumbnail 缩略图地址
30
- * @param {boolean=} config.navigator.vestige 是否显示缩略图浏览痕迹
31
- * @param {number=} config.navigator.vestigeDelay 浏览痕迹颜色时间
32
- * @param {string=} config.navigator.vestigeColor 浏览痕迹颜色
33
- * @param {number=} config.navigator.vestigeZoom 浏览痕迹触发倍率
31
+ * @param {Object} config.navigator.vestige 缩略图浏览痕迹配置
32
+ * @param {boolean=} config.navigator.vestige.show 是否显示缩略图浏览痕迹
33
+ * @param {number=} config.navigator.vestige.delay 浏览痕迹颜色时间
34
+ * @param {string[]=} config.navigator.vestige.colors 浏览痕迹颜色
35
+ * @param {number[]=} config.navigator.vestige.zooms 浏览痕迹触发倍率
34
36
  * @param {Object} config.pxConversion 像素转换参数
35
37
  * @param {number} config.pxConversion.imageCapRes 像素转换倍率
36
38
  * @param {string} config.pxConversion.unit 单位
@@ -56,9 +58,17 @@ export default class KfbView extends EventEmitter {
56
58
  * @param {boolean=} config.board.ROI 是否开启ROI,开启后只能在标注类型是ROI的区域内绘制图形
57
59
  * @param {Object} config.graduation 刻度参数
58
60
  * @param {boolean=} config.graduation.disabled 是否禁用刻度
61
+ * @param {boolean=} config.graduation.show 是否显刻度
59
62
  * @param {boolean=} config.graduation.custom 是否自定义刻度,抛出graduation-change事件
60
63
  * @param {array=} config.graduation.scales 倍率数组
61
64
  * @param {array=} config.graduation.microns 刻度长度数组,在对应倍率范围内显示的刻度长度
65
+ * @param {boolean=} config.grid.disabled 是否禁用网格线
66
+ * @param {boolean=} config.grid.show 是否显示网格线
67
+ * @param {boolean=} config.grid.ruler 是否启用标尺
68
+ * @param {function=} config.measure.handler 标注信息的回调处理
69
+ * @param {boolean=} config.measure.color 标注注释颜色
70
+ * @param {boolean=} config.measure.backgroundColor 标注注释背景色
71
+ * @param {boolean=} config.measure.fontSize 标注注释文字大小
62
72
  * @param {array} config.labelList 标注列表
63
73
  */
64
74
  constructor(config) {
@@ -235,6 +245,7 @@ function initNavigator(kv) {
235
245
  containerHeight: config.height,
236
246
  containerWidth: config.width,
237
247
  element: navigator,
248
+ scale: config.scale,
238
249
  ...config.navigator,
239
250
  });
240
251
  }
@@ -260,7 +271,16 @@ function initComponentsOptions(kv, type) {
260
271
  cache: kv.cache,
261
272
  canvas: createCanvas(kv),
262
273
  options: {
263
- ...config[type], ...pxConversion, thumb: config.thumb ? {
274
+ scale: config.scale,
275
+ measure: {
276
+ backgroundColor: 'rgba(0,0,0,.5)',
277
+ color: '#FFF',
278
+ fontSize: 14,
279
+ ...(config.measure || {}),
280
+ },
281
+ ...config[type],
282
+ ...pxConversion,
283
+ thumb: config.thumb ? {
264
284
  radius: 5,
265
285
  activeRadius: 7,
266
286
  activeBgColor: '#01d0b0',