@idraw/util 0.3.0-beta.3 → 0.3.0-beta.6
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/esm/lib/check.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IDrawContext, BoardSizeOptions } from '@idraw/types';
|
|
2
2
|
type Options = {
|
|
3
3
|
width: number;
|
|
4
4
|
height: number;
|
|
@@ -11,13 +11,13 @@ type Transform = {
|
|
|
11
11
|
scrollX?: number;
|
|
12
12
|
scrollY?: number;
|
|
13
13
|
};
|
|
14
|
-
declare class Context implements
|
|
14
|
+
declare class Context implements IDrawContext {
|
|
15
15
|
private _opts;
|
|
16
16
|
private _ctx;
|
|
17
17
|
private _transform;
|
|
18
18
|
constructor(ctx: CanvasRenderingContext2D, opts: Options);
|
|
19
19
|
getContext(): CanvasRenderingContext2D;
|
|
20
|
-
resetSize(opts:
|
|
20
|
+
resetSize(opts: BoardSizeOptions): void;
|
|
21
21
|
calcDeviceNum(num: number): number;
|
|
22
22
|
calcScreenNum(num: number): number;
|
|
23
23
|
getSize(): {
|
package/dist/esm/lib/context.js
CHANGED
|
@@ -5,7 +5,7 @@ class Context {
|
|
|
5
5
|
this._transform = {
|
|
6
6
|
scale: 1,
|
|
7
7
|
scrollX: 0,
|
|
8
|
-
scrollY: 0
|
|
8
|
+
scrollY: 0
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
getContext() {
|
|
@@ -26,7 +26,7 @@ class Context {
|
|
|
26
26
|
height: this._opts.height,
|
|
27
27
|
contextWidth: this._opts.contextWidth,
|
|
28
28
|
contextHeight: this._opts.contextHeight,
|
|
29
|
-
devicePixelRatio: this._opts.devicePixelRatio
|
|
29
|
+
devicePixelRatio: this._opts.devicePixelRatio
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
setTransform(config) {
|
|
@@ -36,7 +36,7 @@ class Context {
|
|
|
36
36
|
return {
|
|
37
37
|
scale: this._transform.scale,
|
|
38
38
|
scrollX: this._transform.scrollX,
|
|
39
|
-
scrollY: this._transform.scrollY
|
|
39
|
+
scrollY: this._transform.scrollY
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
setFillStyle(color) {
|
|
@@ -73,10 +73,10 @@ class Context {
|
|
|
73
73
|
return this._ctx.arcTo(this._doSize(x1), this._doSize(y1), this._doSize(x2), this._doSize(y2), this._doSize(radius));
|
|
74
74
|
}
|
|
75
75
|
setLineWidth(w) {
|
|
76
|
-
return this._ctx.lineWidth = this._doSize(w);
|
|
76
|
+
return (this._ctx.lineWidth = this._doSize(w));
|
|
77
77
|
}
|
|
78
78
|
setLineDash(nums) {
|
|
79
|
-
return this._ctx.setLineDash(nums.map(n => this._doSize(n)));
|
|
79
|
+
return this._ctx.setLineDash(nums.map((n) => this._doSize(n)));
|
|
80
80
|
}
|
|
81
81
|
isPointInPath(x, y) {
|
|
82
82
|
return this._ctx.isPointInPath(this._doX(x), this._doY(y));
|
package/dist/index.global.js
CHANGED
|
@@ -250,10 +250,22 @@ var iDrawUtil = function(exports) {
|
|
|
250
250
|
return this._ctx.fill(fillRule || "nonzero");
|
|
251
251
|
}
|
|
252
252
|
arc(x2, y2, radius, startAngle, endAngle, anticlockwise) {
|
|
253
|
-
return this._ctx.arc(
|
|
253
|
+
return this._ctx.arc(
|
|
254
|
+
this._doSize(x2),
|
|
255
|
+
this._doSize(y2),
|
|
256
|
+
this._doSize(radius),
|
|
257
|
+
startAngle,
|
|
258
|
+
endAngle,
|
|
259
|
+
anticlockwise
|
|
260
|
+
);
|
|
254
261
|
}
|
|
255
262
|
rect(x2, y2, w2, h2) {
|
|
256
|
-
return this._ctx.rect(
|
|
263
|
+
return this._ctx.rect(
|
|
264
|
+
this._doSize(x2),
|
|
265
|
+
this._doSize(y2),
|
|
266
|
+
this._doSize(w2),
|
|
267
|
+
this._doSize(h2)
|
|
268
|
+
);
|
|
257
269
|
}
|
|
258
270
|
fillRect(x2, y2, w2, h2) {
|
|
259
271
|
return this._ctx.fillRect(
|
|
@@ -284,7 +296,13 @@ var iDrawUtil = function(exports) {
|
|
|
284
296
|
return this._ctx.moveTo(this._doSize(x2), this._doSize(y2));
|
|
285
297
|
}
|
|
286
298
|
arcTo(x1, y1, x2, y2, radius) {
|
|
287
|
-
return this._ctx.arcTo(
|
|
299
|
+
return this._ctx.arcTo(
|
|
300
|
+
this._doSize(x1),
|
|
301
|
+
this._doSize(y1),
|
|
302
|
+
this._doSize(x2),
|
|
303
|
+
this._doSize(y2),
|
|
304
|
+
this._doSize(radius)
|
|
305
|
+
);
|
|
288
306
|
}
|
|
289
307
|
setLineWidth(w2) {
|
|
290
308
|
return this._ctx.lineWidth = this._doSize(w2);
|
|
@@ -321,9 +339,25 @@ var iDrawUtil = function(exports) {
|
|
|
321
339
|
const dw = args[args.length - 2];
|
|
322
340
|
const dh = args[args.length - 1];
|
|
323
341
|
if (args.length === 9) {
|
|
324
|
-
return this._ctx.drawImage(
|
|
342
|
+
return this._ctx.drawImage(
|
|
343
|
+
image,
|
|
344
|
+
this._doSize(sx),
|
|
345
|
+
this._doSize(sy),
|
|
346
|
+
this._doSize(sw),
|
|
347
|
+
this._doSize(sh),
|
|
348
|
+
this._doSize(dx),
|
|
349
|
+
this._doSize(dy),
|
|
350
|
+
this._doSize(dw),
|
|
351
|
+
this._doSize(dh)
|
|
352
|
+
);
|
|
325
353
|
} else {
|
|
326
|
-
return this._ctx.drawImage(
|
|
354
|
+
return this._ctx.drawImage(
|
|
355
|
+
image,
|
|
356
|
+
this._doSize(dx),
|
|
357
|
+
this._doSize(dy),
|
|
358
|
+
this._doSize(dw),
|
|
359
|
+
this._doSize(dh)
|
|
360
|
+
);
|
|
327
361
|
}
|
|
328
362
|
}
|
|
329
363
|
createPattern(image, repetition) {
|
|
@@ -337,14 +371,24 @@ var iDrawUtil = function(exports) {
|
|
|
337
371
|
}
|
|
338
372
|
fillText(text2, x2, y2, maxWidth) {
|
|
339
373
|
if (maxWidth !== void 0) {
|
|
340
|
-
return this._ctx.fillText(
|
|
374
|
+
return this._ctx.fillText(
|
|
375
|
+
text2,
|
|
376
|
+
this._doSize(x2),
|
|
377
|
+
this._doSize(y2),
|
|
378
|
+
this._doSize(maxWidth)
|
|
379
|
+
);
|
|
341
380
|
} else {
|
|
342
381
|
return this._ctx.fillText(text2, this._doSize(x2), this._doSize(y2));
|
|
343
382
|
}
|
|
344
383
|
}
|
|
345
384
|
strokeText(text2, x2, y2, maxWidth) {
|
|
346
385
|
if (maxWidth !== void 0) {
|
|
347
|
-
return this._ctx.strokeText(
|
|
386
|
+
return this._ctx.strokeText(
|
|
387
|
+
text2,
|
|
388
|
+
this._doSize(x2),
|
|
389
|
+
this._doSize(y2),
|
|
390
|
+
this._doSize(maxWidth)
|
|
391
|
+
);
|
|
348
392
|
} else {
|
|
349
393
|
return this._ctx.strokeText(text2, this._doSize(x2), this._doSize(y2));
|
|
350
394
|
}
|
|
@@ -386,7 +430,16 @@ var iDrawUtil = function(exports) {
|
|
|
386
430
|
this._ctx.shadowBlur = this._doSize(blur);
|
|
387
431
|
}
|
|
388
432
|
ellipse(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
|
|
389
|
-
this._ctx.ellipse(
|
|
433
|
+
this._ctx.ellipse(
|
|
434
|
+
this._doSize(x2),
|
|
435
|
+
this._doSize(y2),
|
|
436
|
+
this._doSize(radiusX),
|
|
437
|
+
this._doSize(radiusY),
|
|
438
|
+
rotation,
|
|
439
|
+
startAngle,
|
|
440
|
+
endAngle,
|
|
441
|
+
counterclockwise
|
|
442
|
+
);
|
|
390
443
|
}
|
|
391
444
|
_doSize(num) {
|
|
392
445
|
return this._opts.devicePixelRatio * num;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idraw/util",
|
|
3
|
-
"version": "0.3.0-beta.
|
|
3
|
+
"version": "0.3.0-beta.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"author": "chenshenhai",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@idraw/types": "^0.3.0-beta.
|
|
24
|
+
"@idraw/types": "^0.3.0-beta.6"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "afbadcfac219cd8e1897a080385b730374c980ea"
|
|
30
30
|
}
|