kfb-view 2.2.5 → 2.2.8
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/.idea/workspace.xml +14 -2
- package/example/index.js +1 -1
- package/lib/kfb-view.js +1 -1
- package/package.json +1 -1
- package/src/components/board/index.js +13 -1
- package/src/plugin/openseadragon/openseadragon.js +1 -0
- package/src/tool/Brush.js +1 -1
- package/src/tool/Image.js +13 -8
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
EVENT_IN_PAINTING,
|
|
12
12
|
} from '../../const/event';
|
|
13
13
|
import {
|
|
14
|
+
getAngle,
|
|
14
15
|
getDistance,
|
|
15
16
|
pointInOtherPoint,
|
|
16
17
|
pointsToRegion,
|
|
@@ -344,7 +345,18 @@ export class Board extends ViewerCommon {
|
|
|
344
345
|
if (index === 0) return true;
|
|
345
346
|
if (index === this.points.length - 1) return true;
|
|
346
347
|
if (pointInOtherPoint(firstPoint, _p, 30)) {
|
|
347
|
-
|
|
348
|
+
const nextPoint = points[index + 1];
|
|
349
|
+
if (nextPoint) {
|
|
350
|
+
const deg = Math.abs(getAngle(_p, firstPoint, nextPoint));
|
|
351
|
+
const angle = deg * 180 / Math.PI;
|
|
352
|
+
if (angle < 90) {
|
|
353
|
+
firstPoint = _p;
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
return false;
|
|
357
|
+
} else {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
348
360
|
} else {
|
|
349
361
|
firstPoint = _p;
|
|
350
362
|
return true;
|
|
@@ -17344,6 +17344,7 @@ function OpenSeadragon(options) {
|
|
|
17344
17344
|
sourceHeight: sourceHeight,
|
|
17345
17345
|
position: position,
|
|
17346
17346
|
size: size,
|
|
17347
|
+
pixelDensityRatio: $.pixelDensityRatio,
|
|
17347
17348
|
});
|
|
17348
17349
|
/* context.drawImage(
|
|
17349
17350
|
rendered.canvas,
|
package/src/tool/Brush.js
CHANGED
package/src/tool/Image.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {Brush} from './Brush';
|
|
2
2
|
import {pointsToRegion} from '../util/calculate';
|
|
3
|
+
import {EventEmitter} from '../util/event-emitter';
|
|
4
|
+
|
|
5
|
+
const et = new EventEmitter();
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* 线段类
|
|
@@ -22,18 +25,20 @@ class Image extends Brush {
|
|
|
22
25
|
*/
|
|
23
26
|
draw(points, scale = 1) {
|
|
24
27
|
const region = pointsToRegion(points);
|
|
25
|
-
const ctx = this.canvas.getContext('2d');
|
|
26
|
-
const drawImage = () => {
|
|
27
|
-
ctx.drawImage(this.options.img, region.x, region.y, region.width,
|
|
28
|
-
region.height);
|
|
29
|
-
this.options.img.removeEventListener('load', drawImage);
|
|
30
|
-
};
|
|
31
28
|
if (this.options.imgLoadSuccess) {
|
|
32
|
-
drawImage();
|
|
29
|
+
this.drawImage(this.options.img, region);
|
|
33
30
|
} else if (this.options.img) {
|
|
34
|
-
this.options.img
|
|
31
|
+
const img = this.options.img;
|
|
32
|
+
et.$once('load', () => {
|
|
33
|
+
this.drawImage(img, region);
|
|
34
|
+
}, true, img);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
drawImage(img, region) {
|
|
39
|
+
const ctx = this.canvas.getContext('2d');
|
|
40
|
+
ctx.drawImage(img, region.x, region.y, region.width, region.height);
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
export {
|