modern-canvas 0.1.3 → 0.1.5
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/index.cjs +36 -26
- package/dist/index.d.cts +8 -7
- package/dist/index.d.mts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +28 -28
- package/dist/index.mjs +37 -27
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3392,8 +3392,8 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3392
3392
|
lineWidth;
|
|
3393
3393
|
miterLimit;
|
|
3394
3394
|
_defaultStyle = Texture.EMPTY;
|
|
3395
|
-
|
|
3396
|
-
|
|
3395
|
+
_stroke = [];
|
|
3396
|
+
_fille = [];
|
|
3397
3397
|
stroke() {
|
|
3398
3398
|
let texture = this._defaultStyle;
|
|
3399
3399
|
if (this.strokeStyle) {
|
|
@@ -3404,8 +3404,8 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3404
3404
|
}
|
|
3405
3405
|
}
|
|
3406
3406
|
if (this.curves.length) {
|
|
3407
|
-
this.
|
|
3408
|
-
|
|
3407
|
+
this._stroke.push({
|
|
3408
|
+
path: new modernPath2d.Path2D(this),
|
|
3409
3409
|
texture,
|
|
3410
3410
|
textureTransform: this.textureTransform,
|
|
3411
3411
|
style: {
|
|
@@ -3416,7 +3416,8 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3416
3416
|
miterLimit: this.miterLimit ?? 10
|
|
3417
3417
|
}
|
|
3418
3418
|
});
|
|
3419
|
-
this.
|
|
3419
|
+
this.currentCurve = new modernPath2d.CurvePath();
|
|
3420
|
+
this.curves = [this.currentCurve];
|
|
3420
3421
|
}
|
|
3421
3422
|
}
|
|
3422
3423
|
fillRect(x, y, width, height) {
|
|
@@ -3434,14 +3435,29 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3434
3435
|
texture = new ColorTexture(this.fillStyle);
|
|
3435
3436
|
}
|
|
3436
3437
|
}
|
|
3437
|
-
this.
|
|
3438
|
-
|
|
3438
|
+
this._fille.push({
|
|
3439
|
+
path: new modernPath2d.Path2D(this),
|
|
3439
3440
|
texture,
|
|
3440
3441
|
textureTransform: this.textureTransform
|
|
3441
3442
|
});
|
|
3442
|
-
this.
|
|
3443
|
+
this.currentCurve = new modernPath2d.CurvePath();
|
|
3444
|
+
this.curves = [this.currentCurve];
|
|
3445
|
+
}
|
|
3446
|
+
copy(source) {
|
|
3447
|
+
super.copy(source);
|
|
3448
|
+
this.strokeStyle = source.strokeStyle;
|
|
3449
|
+
this.fillStyle = source.fillStyle;
|
|
3450
|
+
this.textureTransform = source.textureTransform;
|
|
3451
|
+
this.lineCap = source.lineCap;
|
|
3452
|
+
this.lineJoin = source.lineJoin;
|
|
3453
|
+
this.lineWidth = source.lineWidth;
|
|
3454
|
+
this.miterLimit = source.miterLimit;
|
|
3455
|
+
this._stroke = source._stroke.slice();
|
|
3456
|
+
this._fille = source._fille.slice();
|
|
3457
|
+
return this;
|
|
3443
3458
|
}
|
|
3444
3459
|
reset() {
|
|
3460
|
+
super.reset();
|
|
3445
3461
|
this.strokeStyle = void 0;
|
|
3446
3462
|
this.fillStyle = void 0;
|
|
3447
3463
|
this.textureTransform = void 0;
|
|
@@ -3449,9 +3465,9 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3449
3465
|
this.lineJoin = void 0;
|
|
3450
3466
|
this.lineWidth = void 0;
|
|
3451
3467
|
this.miterLimit = void 0;
|
|
3452
|
-
this.
|
|
3453
|
-
this.
|
|
3454
|
-
this
|
|
3468
|
+
this._stroke.length = 0;
|
|
3469
|
+
this._fille.length = 0;
|
|
3470
|
+
return this;
|
|
3455
3471
|
}
|
|
3456
3472
|
buildUvs(start, vertices, uvs, texture, textureTransform) {
|
|
3457
3473
|
if (texture) {
|
|
@@ -3489,15 +3505,11 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3489
3505
|
uvs = [];
|
|
3490
3506
|
texture = void 0;
|
|
3491
3507
|
};
|
|
3492
|
-
for (let len = this.
|
|
3508
|
+
for (let len = this._stroke.length, i = 0; i < len; i++) {
|
|
3493
3509
|
startUv = vertices.length;
|
|
3494
|
-
const graphics = this.
|
|
3510
|
+
const graphics = this._stroke[i];
|
|
3495
3511
|
texture ??= graphics.texture;
|
|
3496
|
-
|
|
3497
|
-
for (let len2 = graphics.shapes.length, i2 = 0; i2 < len2; i2++) {
|
|
3498
|
-
graphics.shapes[i2].getAdaptivePointArray(points);
|
|
3499
|
-
}
|
|
3500
|
-
modernPath2d.strokeTriangulate(points, {
|
|
3512
|
+
graphics.path.strokeTriangulate({
|
|
3501
3513
|
vertices,
|
|
3502
3514
|
indices,
|
|
3503
3515
|
lineStyle: graphics.style,
|
|
@@ -3507,19 +3519,17 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3507
3519
|
this.buildUvs(startUv, vertices, uvs, graphics.texture, graphics.textureTransform);
|
|
3508
3520
|
push("stroke");
|
|
3509
3521
|
}
|
|
3510
|
-
for (let len = this.
|
|
3511
|
-
const graphics = this.
|
|
3522
|
+
for (let len = this._fille.length, i = 0; i < len; i++) {
|
|
3523
|
+
const graphics = this._fille[i];
|
|
3512
3524
|
texture ??= graphics.texture;
|
|
3513
3525
|
if (texture !== graphics.texture) {
|
|
3514
3526
|
push("fill");
|
|
3515
3527
|
}
|
|
3516
3528
|
startUv = vertices.length;
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
});
|
|
3522
|
-
}
|
|
3529
|
+
graphics.path.fillTriangulate({
|
|
3530
|
+
vertices,
|
|
3531
|
+
indices
|
|
3532
|
+
});
|
|
3523
3533
|
this.buildUvs(startUv, vertices, uvs, graphics.texture, graphics.textureTransform);
|
|
3524
3534
|
}
|
|
3525
3535
|
if (vertices.length) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Visibility, Overflow, IDOCTextStyleDeclaration, IDOCTransformStyleDeclaration } from 'modern-idoc';
|
|
2
|
-
import {
|
|
2
|
+
import { Path2D, LineStyle, LineCap, LineJoin, BoundingBox } from 'modern-path2d';
|
|
3
3
|
import { AnyColor, Colord } from 'colord';
|
|
4
4
|
import { AnimationItem } from 'lottie-web';
|
|
5
5
|
import { TextOptions, Text, MeasureResult } from 'modern-text';
|
|
@@ -1488,13 +1488,13 @@ interface CanvasBatchable extends Batchable2D {
|
|
|
1488
1488
|
texture?: Texture;
|
|
1489
1489
|
}
|
|
1490
1490
|
interface StrokedGraphics {
|
|
1491
|
-
|
|
1491
|
+
path: Path2D;
|
|
1492
1492
|
texture?: Texture;
|
|
1493
1493
|
textureTransform?: Transform2D;
|
|
1494
1494
|
style: LineStyle;
|
|
1495
1495
|
}
|
|
1496
1496
|
interface FilledGraphics {
|
|
1497
|
-
|
|
1497
|
+
path: Path2D;
|
|
1498
1498
|
texture?: Texture;
|
|
1499
1499
|
textureTransform?: Transform2D;
|
|
1500
1500
|
}
|
|
@@ -1506,14 +1506,15 @@ declare class CanvasContext extends Path2D {
|
|
|
1506
1506
|
lineJoin?: LineJoin;
|
|
1507
1507
|
lineWidth?: number;
|
|
1508
1508
|
miterLimit?: number;
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1509
|
+
_defaultStyle: Texture<TextureSource>;
|
|
1510
|
+
_stroke: StrokedGraphics[];
|
|
1511
|
+
_fille: FilledGraphics[];
|
|
1512
1512
|
stroke(): void;
|
|
1513
1513
|
fillRect(x: number, y: number, width: number, height: number): void;
|
|
1514
1514
|
strokeRect(x: number, y: number, width: number, height: number): void;
|
|
1515
1515
|
fill(): void;
|
|
1516
|
-
|
|
1516
|
+
copy(source: CanvasContext): this;
|
|
1517
|
+
reset(): this;
|
|
1517
1518
|
buildUvs(start: number, vertices: number[], uvs: number[], texture?: Texture, textureTransform?: Transform2D): void;
|
|
1518
1519
|
toBatchables(): CanvasBatchable[];
|
|
1519
1520
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Visibility, Overflow, IDOCTextStyleDeclaration, IDOCTransformStyleDeclaration } from 'modern-idoc';
|
|
2
|
-
import {
|
|
2
|
+
import { Path2D, LineStyle, LineCap, LineJoin, BoundingBox } from 'modern-path2d';
|
|
3
3
|
import { AnyColor, Colord } from 'colord';
|
|
4
4
|
import { AnimationItem } from 'lottie-web';
|
|
5
5
|
import { TextOptions, Text, MeasureResult } from 'modern-text';
|
|
@@ -1488,13 +1488,13 @@ interface CanvasBatchable extends Batchable2D {
|
|
|
1488
1488
|
texture?: Texture;
|
|
1489
1489
|
}
|
|
1490
1490
|
interface StrokedGraphics {
|
|
1491
|
-
|
|
1491
|
+
path: Path2D;
|
|
1492
1492
|
texture?: Texture;
|
|
1493
1493
|
textureTransform?: Transform2D;
|
|
1494
1494
|
style: LineStyle;
|
|
1495
1495
|
}
|
|
1496
1496
|
interface FilledGraphics {
|
|
1497
|
-
|
|
1497
|
+
path: Path2D;
|
|
1498
1498
|
texture?: Texture;
|
|
1499
1499
|
textureTransform?: Transform2D;
|
|
1500
1500
|
}
|
|
@@ -1506,14 +1506,15 @@ declare class CanvasContext extends Path2D {
|
|
|
1506
1506
|
lineJoin?: LineJoin;
|
|
1507
1507
|
lineWidth?: number;
|
|
1508
1508
|
miterLimit?: number;
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1509
|
+
_defaultStyle: Texture<TextureSource>;
|
|
1510
|
+
_stroke: StrokedGraphics[];
|
|
1511
|
+
_fille: FilledGraphics[];
|
|
1512
1512
|
stroke(): void;
|
|
1513
1513
|
fillRect(x: number, y: number, width: number, height: number): void;
|
|
1514
1514
|
strokeRect(x: number, y: number, width: number, height: number): void;
|
|
1515
1515
|
fill(): void;
|
|
1516
|
-
|
|
1516
|
+
copy(source: CanvasContext): this;
|
|
1517
|
+
reset(): this;
|
|
1517
1518
|
buildUvs(start: number, vertices: number[], uvs: number[], texture?: Texture, textureTransform?: Transform2D): void;
|
|
1518
1519
|
toBatchables(): CanvasBatchable[];
|
|
1519
1520
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Visibility, Overflow, IDOCTextStyleDeclaration, IDOCTransformStyleDeclaration } from 'modern-idoc';
|
|
2
|
-
import {
|
|
2
|
+
import { Path2D, LineStyle, LineCap, LineJoin, BoundingBox } from 'modern-path2d';
|
|
3
3
|
import { AnyColor, Colord } from 'colord';
|
|
4
4
|
import { AnimationItem } from 'lottie-web';
|
|
5
5
|
import { TextOptions, Text, MeasureResult } from 'modern-text';
|
|
@@ -1488,13 +1488,13 @@ interface CanvasBatchable extends Batchable2D {
|
|
|
1488
1488
|
texture?: Texture;
|
|
1489
1489
|
}
|
|
1490
1490
|
interface StrokedGraphics {
|
|
1491
|
-
|
|
1491
|
+
path: Path2D;
|
|
1492
1492
|
texture?: Texture;
|
|
1493
1493
|
textureTransform?: Transform2D;
|
|
1494
1494
|
style: LineStyle;
|
|
1495
1495
|
}
|
|
1496
1496
|
interface FilledGraphics {
|
|
1497
|
-
|
|
1497
|
+
path: Path2D;
|
|
1498
1498
|
texture?: Texture;
|
|
1499
1499
|
textureTransform?: Transform2D;
|
|
1500
1500
|
}
|
|
@@ -1506,14 +1506,15 @@ declare class CanvasContext extends Path2D {
|
|
|
1506
1506
|
lineJoin?: LineJoin;
|
|
1507
1507
|
lineWidth?: number;
|
|
1508
1508
|
miterLimit?: number;
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1509
|
+
_defaultStyle: Texture<TextureSource>;
|
|
1510
|
+
_stroke: StrokedGraphics[];
|
|
1511
|
+
_fille: FilledGraphics[];
|
|
1512
1512
|
stroke(): void;
|
|
1513
1513
|
fillRect(x: number, y: number, width: number, height: number): void;
|
|
1514
1514
|
strokeRect(x: number, y: number, width: number, height: number): void;
|
|
1515
1515
|
fill(): void;
|
|
1516
|
-
|
|
1516
|
+
copy(source: CanvasContext): this;
|
|
1517
|
+
reset(): this;
|
|
1517
1518
|
buildUvs(start: number, vertices: number[], uvs: number[], texture?: Texture, textureTransform?: Transform2D): void;
|
|
1518
1519
|
toBatchables(): CanvasBatchable[];
|
|
1519
1520
|
}
|