@inweb/markup 26.5.1 → 26.5.3
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/dist/markup.js +75 -53
- package/dist/markup.js.map +1 -1
- package/dist/markup.min.js +1 -1
- package/dist/markup.module.js +73 -55
- package/dist/markup.module.js.map +1 -1
- package/package.json +3 -3
- package/src/markup/Konva/KonvaCloud.ts +68 -48
- package/src/markup/Konva/KonvaEllipse.ts +1 -0
- package/src/markup/Konva/KonvaImage.ts +6 -6
package/dist/markup.js
CHANGED
|
@@ -12573,7 +12573,7 @@
|
|
|
12573
12573
|
///////////////////////////////////////////////////////////////////////////////
|
|
12574
12574
|
class KonvaEllipse {
|
|
12575
12575
|
constructor(params, ref = null, worldTransformer = new WorldTransform()) {
|
|
12576
|
-
var _a, _b;
|
|
12576
|
+
var _a, _b, _c;
|
|
12577
12577
|
this._worldTransformer = worldTransformer;
|
|
12578
12578
|
if (ref) {
|
|
12579
12579
|
this._ref = ref;
|
|
@@ -12596,6 +12596,7 @@
|
|
|
12596
12596
|
if (!params.position)
|
|
12597
12597
|
params.position = { x: 0, y: 0 };
|
|
12598
12598
|
if (params.position2) {
|
|
12599
|
+
(_a = params.radius) !== null && _a !== undefined ? _a : (params.radius = { x: 0, y: 0 });
|
|
12599
12600
|
params.radius.x = getDistanceIn2D(params.position, params.position2);
|
|
12600
12601
|
if (params.position3)
|
|
12601
12602
|
params.radius.y = getDistanceIn2D(params.position, params.position3);
|
|
@@ -12607,8 +12608,8 @@
|
|
|
12607
12608
|
params.radius = { x: 25, y: 25 };
|
|
12608
12609
|
}
|
|
12609
12610
|
this._ref = new Konva.Ellipse({
|
|
12610
|
-
stroke: (
|
|
12611
|
-
strokeWidth: (
|
|
12611
|
+
stroke: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
|
|
12612
|
+
strokeWidth: (_c = params.lineWidth) !== null && _c !== undefined ? _c : 4,
|
|
12612
12613
|
globalCompositeOperation: "source-over",
|
|
12613
12614
|
lineCap: "round",
|
|
12614
12615
|
lineJoin: "round",
|
|
@@ -12992,13 +12993,13 @@
|
|
|
12992
12993
|
this._ref.width(params.maxHeight / this._ratio);
|
|
12993
12994
|
this._ref.height(params.maxHeight);
|
|
12994
12995
|
}
|
|
12995
|
-
const wcsEnd = this._worldTransformer.screenToWorld({
|
|
12996
|
-
x: params.position.x + this._ref.width(),
|
|
12997
|
-
y: params.position.y + this._ref.height(),
|
|
12998
|
-
});
|
|
12999
|
-
this._ref.setAttr("wcsEnd", wcsEnd);
|
|
13000
12996
|
}
|
|
13001
12997
|
}
|
|
12998
|
+
const wcsEnd = this._worldTransformer.screenToWorld({
|
|
12999
|
+
x: params.position.x + this._ref.width(),
|
|
13000
|
+
y: params.position.y + this._ref.height(),
|
|
13001
|
+
});
|
|
13002
|
+
this._ref.setAttr("wcsEnd", wcsEnd);
|
|
13002
13003
|
};
|
|
13003
13004
|
this._canvasImage.onerror = () => {
|
|
13004
13005
|
this._canvasImage.onerror = function () { };
|
|
@@ -13194,7 +13195,10 @@
|
|
|
13194
13195
|
params.position2 = { x: params.position.x + params.width, y: params.position.y + params.height };
|
|
13195
13196
|
}
|
|
13196
13197
|
}
|
|
13197
|
-
const ARC_RADIUS =
|
|
13198
|
+
const ARC_RADIUS = 8;
|
|
13199
|
+
const ARC_LENGTH = 15;
|
|
13200
|
+
const MIN_CLOUD_WIDTH = 50;
|
|
13201
|
+
const MIN_CLOUD_HEIGHT = 50;
|
|
13198
13202
|
this._ref = new Konva.Shape({
|
|
13199
13203
|
x: params.position.x,
|
|
13200
13204
|
y: params.position.y,
|
|
@@ -13206,51 +13210,71 @@
|
|
|
13206
13210
|
strokeScaleEnabled: false,
|
|
13207
13211
|
globalCompositeOperation: "source-over",
|
|
13208
13212
|
sceneFunc: (context, shape) => {
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
const midY = position.y + height / 2;
|
|
13212
|
-
return { x: midX, y: midY };
|
|
13213
|
-
}
|
|
13213
|
+
const width = this._ref.width();
|
|
13214
|
+
const height = this._ref.height();
|
|
13214
13215
|
const points = [
|
|
13215
13216
|
{ x: 0, y: 0 },
|
|
13216
|
-
{ x: 0 +
|
|
13217
|
-
{ x: 0 +
|
|
13218
|
-
{ x: 0, y: 0 +
|
|
13217
|
+
{ x: 0 + width, y: 0 },
|
|
13218
|
+
{ x: 0 + width, y: 0 + height },
|
|
13219
|
+
{ x: 0, y: 0 + height },
|
|
13219
13220
|
{ x: 0, y: 0 },
|
|
13220
13221
|
];
|
|
13221
|
-
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
|
|
13225
|
-
|
|
13226
|
-
|
|
13227
|
-
|
|
13228
|
-
const
|
|
13229
|
-
const
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
|
|
13233
|
-
|
|
13234
|
-
|
|
13235
|
-
|
|
13236
|
-
|
|
13237
|
-
|
|
13238
|
-
|
|
13239
|
-
|
|
13240
|
-
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13222
|
+
if (width >= MIN_CLOUD_WIDTH - 1 || height >= MIN_CLOUD_HEIGHT - 1)
|
|
13223
|
+
drawCloud(ARC_RADIUS, ARC_LENGTH);
|
|
13224
|
+
else if (width >= MIN_CLOUD_WIDTH / 2 || height >= MIN_CLOUD_HEIGHT / 2)
|
|
13225
|
+
drawCloud(ARC_RADIUS / 2, ARC_LENGTH / 2);
|
|
13226
|
+
else
|
|
13227
|
+
drawRectangle();
|
|
13228
|
+
function calculateMidpoint(position) {
|
|
13229
|
+
const midX = position.x + width / 2;
|
|
13230
|
+
const midY = position.y + height / 2;
|
|
13231
|
+
return { x: midX, y: midY };
|
|
13232
|
+
}
|
|
13233
|
+
function drawCloud(arcRadius, arcLength) {
|
|
13234
|
+
const midPoint = calculateMidpoint({ x: 0, y: 0 });
|
|
13235
|
+
context.beginPath();
|
|
13236
|
+
for (let iPoint = 0; iPoint < points.length - 1; iPoint++) {
|
|
13237
|
+
let approxArcLength = arcLength;
|
|
13238
|
+
const dx = points[iPoint + 1].x - points[iPoint].x;
|
|
13239
|
+
const dy = points[iPoint + 1].y - points[iPoint].y;
|
|
13240
|
+
const length = Math.sqrt(dx * dx + dy * dy);
|
|
13241
|
+
const arcCount = Math.floor(length / approxArcLength);
|
|
13242
|
+
const lengthMod = length % approxArcLength;
|
|
13243
|
+
approxArcLength = arcLength + arcCount / lengthMod;
|
|
13244
|
+
let pX = points[iPoint].x + dx / arcCount / 2;
|
|
13245
|
+
let pY = points[iPoint].y + dy / arcCount / 2;
|
|
13246
|
+
const pEndX = points[iPoint + 1].x;
|
|
13247
|
+
const pEndY = points[iPoint + 1].y;
|
|
13248
|
+
const endAngle = Math.atan((pEndY - pY) / (pEndX - pX));
|
|
13249
|
+
const startAngle = endAngle + Math.PI;
|
|
13250
|
+
const counterClockwise = pX > midPoint.x && pY > midPoint.y;
|
|
13251
|
+
for (let iArc = 0; iArc < arcCount; iArc++) {
|
|
13252
|
+
if (counterClockwise) {
|
|
13253
|
+
context.arc(pX, pY, arcRadius, endAngle, startAngle);
|
|
13254
|
+
}
|
|
13255
|
+
else {
|
|
13256
|
+
context.arc(pX, pY, arcRadius, startAngle, endAngle);
|
|
13257
|
+
}
|
|
13258
|
+
pX += dx / arcCount;
|
|
13259
|
+
pY += dy / arcCount;
|
|
13245
13260
|
}
|
|
13246
|
-
pX += dx / arcCount;
|
|
13247
|
-
pY += dy / arcCount;
|
|
13248
13261
|
}
|
|
13262
|
+
context.closePath();
|
|
13263
|
+
// (!) Konva specific method, it is very important
|
|
13264
|
+
// it will apply are required styles
|
|
13265
|
+
context.fillStrokeShape(shape);
|
|
13266
|
+
}
|
|
13267
|
+
function drawRectangle() {
|
|
13268
|
+
context.beginPath();
|
|
13269
|
+
context.lineTo(points[1].x, points[1].y);
|
|
13270
|
+
context.lineTo(points[2].x, points[2].y);
|
|
13271
|
+
context.lineTo(points[3].x, points[3].y);
|
|
13272
|
+
context.lineTo(points[4].x, points[4].y);
|
|
13273
|
+
context.closePath();
|
|
13274
|
+
// (!) Konva specific method, it is very important
|
|
13275
|
+
// it will apply are required styles
|
|
13276
|
+
context.fillStrokeShape(shape);
|
|
13249
13277
|
}
|
|
13250
|
-
context.closePath();
|
|
13251
|
-
// (!) Konva specific method, it is very important
|
|
13252
|
-
// it will apply are required styles
|
|
13253
|
-
context.fillStrokeShape(shape);
|
|
13254
13278
|
},
|
|
13255
13279
|
});
|
|
13256
13280
|
this._ref.className = "Cloud";
|
|
@@ -13266,12 +13290,10 @@
|
|
|
13266
13290
|
let newHeight = this._ref.height();
|
|
13267
13291
|
if (scaleByY)
|
|
13268
13292
|
newHeight *= attrs.scaleY;
|
|
13269
|
-
|
|
13270
|
-
|
|
13271
|
-
if (
|
|
13272
|
-
|
|
13273
|
-
if (newHeight < minHeight)
|
|
13274
|
-
newHeight = minHeight;
|
|
13293
|
+
if (newWidth < MIN_CLOUD_WIDTH)
|
|
13294
|
+
newWidth = MIN_CLOUD_WIDTH;
|
|
13295
|
+
if (newHeight < MIN_CLOUD_HEIGHT)
|
|
13296
|
+
newHeight = MIN_CLOUD_HEIGHT;
|
|
13275
13297
|
if (scaleByX) {
|
|
13276
13298
|
this._ref.width(newWidth);
|
|
13277
13299
|
}
|