modern-canvas 0.4.23 → 0.4.25

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 CHANGED
@@ -7081,7 +7081,7 @@ class CanvasContext extends modernPath2d.Path2D {
7081
7081
  miterLimit;
7082
7082
  _defaultStyle = Texture2D.EMPTY;
7083
7083
  _draws = [];
7084
- stroke() {
7084
+ stroke(options) {
7085
7085
  let texture = this._defaultStyle;
7086
7086
  if (this.strokeStyle) {
7087
7087
  if (this.strokeStyle instanceof Texture2D) {
@@ -7092,6 +7092,7 @@ class CanvasContext extends modernPath2d.Path2D {
7092
7092
  }
7093
7093
  if (this.curves.length) {
7094
7094
  this._draws.push({
7095
+ ...options,
7095
7096
  type: "stroke",
7096
7097
  path: new modernPath2d.Path2D(this),
7097
7098
  texture,
@@ -7113,7 +7114,7 @@ class CanvasContext extends modernPath2d.Path2D {
7113
7114
  strokeRect(x, y, width, height) {
7114
7115
  this.rect(x, y, width, height).stroke();
7115
7116
  }
7116
- fill() {
7117
+ fill(options) {
7117
7118
  let texture = this._defaultStyle;
7118
7119
  if (this.fillStyle) {
7119
7120
  if (this.fillStyle instanceof Texture2D) {
@@ -7123,6 +7124,7 @@ class CanvasContext extends modernPath2d.Path2D {
7123
7124
  }
7124
7125
  }
7125
7126
  this._draws.push({
7127
+ ...options,
7126
7128
  type: "fill",
7127
7129
  path: new modernPath2d.Path2D(this),
7128
7130
  texture,
@@ -7182,13 +7184,14 @@ class CanvasContext extends modernPath2d.Path2D {
7182
7184
  let indices = [];
7183
7185
  let uvs = [];
7184
7186
  let texture;
7185
- const push = (type) => {
7187
+ const push = (draw) => {
7186
7188
  batchables.push({
7187
- type,
7188
7189
  vertices,
7189
7190
  indices,
7190
7191
  uvs,
7191
- texture
7192
+ texture,
7193
+ type: draw.type,
7194
+ disableWrapMode: draw.disableWrapMode
7192
7195
  });
7193
7196
  vertices = [];
7194
7197
  indices = [];
@@ -7199,14 +7202,14 @@ class CanvasContext extends modernPath2d.Path2D {
7199
7202
  const draw = this._draws[i];
7200
7203
  const prev = this._draws[i - 1];
7201
7204
  if (vertices.length && prev && prev?.type !== draw.type) {
7202
- push(prev.type);
7205
+ push(prev);
7203
7206
  }
7204
7207
  const oldTexture = texture;
7205
7208
  if (!oldTexture) {
7206
7209
  texture = draw.texture;
7207
7210
  }
7208
7211
  if (vertices.length && oldTexture !== draw.texture && !oldTexture?.is(draw.texture)) {
7209
- push(draw.type);
7212
+ push(draw);
7210
7213
  texture = draw.texture;
7211
7214
  }
7212
7215
  const start = vertices.length;
@@ -7229,7 +7232,7 @@ class CanvasContext extends modernPath2d.Path2D {
7229
7232
  }
7230
7233
  const last = this._draws[this._draws.length - 1];
7231
7234
  if (last && vertices.length) {
7232
- push(last.type);
7235
+ push(last);
7233
7236
  }
7234
7237
  return batchables;
7235
7238
  }
@@ -7257,7 +7260,6 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
7257
7260
  return this._globalOpacity ?? 1;
7258
7261
  }
7259
7262
  _modulate = new Color(4294967295);
7260
- _backgroundImage;
7261
7263
  // Batch render
7262
7264
  context = new CanvasContext();
7263
7265
  _resetContext = true;
@@ -8918,13 +8920,40 @@ class BaseElement2DFill extends CoreObject {
8918
8920
  draw() {
8919
8921
  const ctx = this.parent.context;
8920
8922
  if (this._image) {
8923
+ const { width: imageWidth, height: imageHeight } = this._image;
8921
8924
  const { width, height } = this.parent.size;
8922
- ctx.textureTransform = new Transform2D().scale(1 / width, 1 / height);
8925
+ const transform = new Transform2D();
8926
+ if (this.tile) {
8927
+ const {
8928
+ translateX = 0,
8929
+ translateY = 0,
8930
+ scaleX = 1,
8931
+ scaleY = 1
8932
+ // flip, TODO
8933
+ // alignment, TODO
8934
+ } = this.tile;
8935
+ transform.scale(1 / imageWidth, 1 / imageHeight).scale(1 / scaleX, 1 / scaleY).translate(-translateX / imageWidth, -translateY / imageHeight);
8936
+ } else if (this.stretch) {
8937
+ const { left = 0, top = 0, right = 0, bottom = 0 } = this.stretch.rect ?? {};
8938
+ const w = Math.abs(1 + (-left + -right)) * width;
8939
+ const h = Math.abs(1 + (-top + -bottom)) * height;
8940
+ const scaleX = 1 / w;
8941
+ const scaleY = 1 / h;
8942
+ const translateX = -left * width * scaleX;
8943
+ const translateY = -top * height * scaleY;
8944
+ transform.scale(scaleX, scaleY).translate(translateX, translateY);
8945
+ } else {
8946
+ transform.scale(1 / width, 1 / height);
8947
+ }
8948
+ ctx.textureTransform = transform;
8923
8949
  ctx.fillStyle = this._image;
8950
+ ctx.fill({
8951
+ disableWrapMode: true
8952
+ });
8924
8953
  } else {
8925
8954
  ctx.fillStyle = this.color;
8955
+ ctx.fill();
8926
8956
  }
8927
- ctx.fill();
8928
8957
  }
8929
8958
  }
8930
8959
  __decorateClass$s([
@@ -8942,6 +8971,9 @@ __decorateClass$s([
8942
8971
  __decorateClass$s([
8943
8972
  property()
8944
8973
  ], BaseElement2DFill.prototype, "tile");
8974
+ __decorateClass$s([
8975
+ property()
8976
+ ], BaseElement2DFill.prototype, "stretch");
8945
8977
 
8946
8978
  var __defProp$k = Object.defineProperty;
8947
8979
  var __decorateClass$r = (decorators, target, key, kind) => {
@@ -8993,14 +9025,27 @@ class BaseElement2DGeometry extends CoreObject {
8993
9025
  });
8994
9026
  }
8995
9027
  draw() {
9028
+ if (this._path2DSet.paths.length) {
9029
+ const ctx = this.parent.context;
9030
+ const { width, height } = this.parent.size;
9031
+ this._path2DSet.paths.forEach((path) => {
9032
+ ctx.addPath(path.clone().applyTransform(new modernPath2d.Matrix3().scale(width, height)));
9033
+ });
9034
+ } else {
9035
+ this.drawRect();
9036
+ }
9037
+ }
9038
+ drawRect() {
8996
9039
  const ctx = this.parent.context;
8997
9040
  const { width, height } = this.parent.size;
8998
- this._path2DSet.paths.forEach((path) => {
8999
- modernPath2d.svgPathCommandsAddToPath2D(
9000
- path.clone().applyTransform(new modernPath2d.Matrix3().scale(width, height)).toCommands(),
9001
- ctx
9002
- );
9003
- });
9041
+ const { borderRadius } = this.parent.style;
9042
+ if (width && height) {
9043
+ if (borderRadius) {
9044
+ ctx.roundRect(0, 0, width, height, borderRadius);
9045
+ } else {
9046
+ ctx.rect(0, 0, width, height);
9047
+ }
9048
+ }
9004
9049
  }
9005
9050
  }
9006
9051
  __decorateClass$r([
@@ -9013,7 +9058,7 @@ __decorateClass$r([
9013
9058
  property({ default: [0, 0, 1, 1] })
9014
9059
  ], BaseElement2DGeometry.prototype, "viewBox");
9015
9060
  __decorateClass$r([
9016
- property({ default: [{ data: "M0,0L0,1L1,1L1,0Z" }] })
9061
+ property({ default: [] })
9017
9062
  ], BaseElement2DGeometry.prototype, "data");
9018
9063
 
9019
9064
  var __defProp$j = Object.defineProperty;
@@ -9179,7 +9224,7 @@ class BaseElement2DText extends CoreObject {
9179
9224
  measureDom;
9180
9225
  fonts;
9181
9226
  texture = new CanvasTexture();
9182
- text = new modernText.Text();
9227
+ baseText = new modernText.Text();
9183
9228
  measureResult;
9184
9229
  _updateProperty(key, value, oldValue, declaration) {
9185
9230
  super._updateProperty(key, value, oldValue, declaration);
@@ -9194,16 +9239,21 @@ class BaseElement2DText extends CoreObject {
9194
9239
  }
9195
9240
  }
9196
9241
  _updateText() {
9197
- this.text.style = this.parent.style.toJSON();
9198
- this.text.content = this.content ?? "";
9199
- this.text.effects = this.effects;
9200
- this.text.fonts = this.fonts;
9201
- this.text.measureDom = this.measureDom;
9202
- this.text.requestUpdate();
9242
+ this.baseText.style = {
9243
+ justifyContent: "center",
9244
+ alignItems: "center",
9245
+ textAlign: "center",
9246
+ ...this.parent.style.toJSON()
9247
+ };
9248
+ this.baseText.content = this.content ?? "";
9249
+ this.baseText.effects = this.effects;
9250
+ this.baseText.fonts = this.fonts;
9251
+ this.baseText.measureDom = this.measureDom;
9252
+ this.baseText.requestUpdate();
9203
9253
  }
9204
9254
  measure() {
9205
9255
  this._updateText();
9206
- return this.text.measure();
9256
+ return this.baseText.measure();
9207
9257
  }
9208
9258
  updateMeasure() {
9209
9259
  this.measureResult = this.measure();
@@ -9223,7 +9273,7 @@ class BaseElement2DText extends CoreObject {
9223
9273
  }
9224
9274
  draw() {
9225
9275
  const ctx = this.parent.context;
9226
- this.text.render({
9276
+ this.baseText.render({
9227
9277
  pixelRatio: this.texture.pixelRatio,
9228
9278
  view: this.texture.source
9229
9279
  });
@@ -9453,12 +9503,6 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
9453
9503
  this.requestRelayout();
9454
9504
  break;
9455
9505
  /** draw */
9456
- case "backgroundColor":
9457
- this._updateBackgroundColor();
9458
- break;
9459
- case "backgroundImage":
9460
- this._updateBackgroundImage();
9461
- break;
9462
9506
  case "opacity":
9463
9507
  this.opacity = this.style.opacity;
9464
9508
  break;
@@ -9474,6 +9518,24 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
9474
9518
  case "borderRadius":
9475
9519
  this.requestRedraw();
9476
9520
  break;
9521
+ case "backgroundColor":
9522
+ this.fill.color = this.style.backgroundColor;
9523
+ break;
9524
+ case "backgroundImage":
9525
+ this.fill.image = this.style.backgroundImage;
9526
+ break;
9527
+ case "borderStyle":
9528
+ case "outlineStyle":
9529
+ this.outline.style = value;
9530
+ break;
9531
+ case "borderWidth":
9532
+ case "outlineWidth":
9533
+ this.outline.width = value;
9534
+ break;
9535
+ case "borderColor":
9536
+ case "outlineColor":
9537
+ this.outline.color = value;
9538
+ break;
9477
9539
  }
9478
9540
  }
9479
9541
  _updateMaskImage() {
@@ -9493,18 +9555,6 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
9493
9555
  }
9494
9556
  }
9495
9557
  }
9496
- _updateBackgroundColor() {
9497
- const backgroundColor = this.style.getComputedBackgroundColor();
9498
- if (this._originalBatchables.length) {
9499
- this.requestRepaint();
9500
- } else if (backgroundColor.a > 0) {
9501
- this.requestRedraw();
9502
- }
9503
- }
9504
- async _updateBackgroundImage() {
9505
- this._backgroundImage = await this.style.loadBackgroundImage();
9506
- this.requestRedraw();
9507
- }
9508
9558
  _updateTransform() {
9509
9559
  const { width, height } = this.size;
9510
9560
  const [originX, originY] = parseCSSTransformOrigin(this.style.transformOrigin);
@@ -9564,7 +9614,6 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
9564
9614
  }
9565
9615
  _draw() {
9566
9616
  super._draw();
9567
- let flag = false;
9568
9617
  if (this.text.canDraw()) {
9569
9618
  this.text.updateMeasure();
9570
9619
  }
@@ -9572,81 +9621,26 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
9572
9621
  this._tree?.log(this.name, "draw fill");
9573
9622
  this.geometry.draw();
9574
9623
  this.fill.draw();
9575
- flag = true;
9576
9624
  }
9577
9625
  if (this.outline.canDraw()) {
9578
9626
  this._tree?.log(this.name, "draw outline");
9579
9627
  this.geometry.draw();
9580
9628
  this.outline.draw();
9581
- flag = true;
9582
9629
  }
9583
9630
  if (this.text.canDraw()) {
9584
9631
  this._tree?.log(this.name, "draw text");
9585
- this._drawBoundingRect();
9632
+ this.geometry.drawRect();
9586
9633
  this.text.draw();
9587
- flag = true;
9588
- }
9589
- if (!flag) {
9590
- this._drawBackground();
9591
- this._drawContent();
9592
- this._drawBorder();
9593
- this._drawOutline();
9594
- }
9595
- }
9596
- _drawBackground() {
9597
- const texture = this._backgroundImage;
9598
- if (texture?.valid) {
9599
- const { width, height } = this.size;
9600
- this.context.fillStyle = texture;
9601
- this.context.textureTransform = new Transform2D().scale(
9602
- 1 / width,
9603
- 1 / height
9604
- );
9605
- this._fillBoundingRect();
9606
9634
  }
9635
+ this._drawContent();
9607
9636
  }
9608
9637
  _drawContent() {
9609
- this._fillBoundingRect();
9610
- }
9611
- _drawBorder() {
9612
- if (this.style.borderWidth && this.style.borderStyle !== "none") {
9613
- this.context.lineWidth = this.style.borderWidth;
9614
- this.context.strokeStyle = this.style.borderColor;
9615
- this._strokeBoundingRect();
9616
- }
9617
- }
9618
- _drawOutline() {
9619
- if (this.style.outlineWidth && this.style.outlineColor !== "none") {
9620
- this.context.lineWidth = this.style.outlineWidth;
9621
- this.context.strokeStyle = this.style.outlineColor;
9622
- this._strokeBoundingRect();
9623
- }
9624
- }
9625
- _drawBoundingRect() {
9626
- const { borderRadius } = this.style;
9627
- const { width, height } = this.size;
9628
- if (width && height) {
9629
- if (borderRadius) {
9630
- this.context.roundRect(0, 0, width, height, borderRadius);
9631
- } else {
9632
- this.context.rect(0, 0, width, height);
9633
- }
9634
- }
9635
- }
9636
- _fillBoundingRect() {
9637
- this._drawBoundingRect();
9638
- this.context.fill();
9639
- }
9640
- _strokeBoundingRect() {
9641
- this._drawBoundingRect();
9642
- this.context.stroke();
9643
9638
  }
9644
9639
  _repaint(batchables) {
9645
9640
  const colorMatrix = parseCSSFilter(this.style.filter);
9646
9641
  return super._repaint(batchables).map((batchable) => {
9647
9642
  return {
9648
9643
  ...batchable,
9649
- backgroundColor: this.style.getComputedBackgroundColor().abgr,
9650
9644
  colorMatrix: colorMatrix.toMatrix4().toArray(true),
9651
9645
  colorMatrixOffset: colorMatrix.toVector4().toArray()
9652
9646
  };
@@ -9764,11 +9758,11 @@ exports.Element2D = class Element2D extends exports.BaseElement2D {
9764
9758
  break;
9765
9759
  case "width":
9766
9760
  this.size.width = Number(value);
9767
- this.requestRelayout();
9761
+ this.requestRedraw();
9768
9762
  break;
9769
9763
  case "height":
9770
9764
  this.size.height = Number(value);
9771
- this.requestRelayout();
9765
+ this.requestRedraw();
9772
9766
  break;
9773
9767
  }
9774
9768
  }
@@ -10349,7 +10343,8 @@ exports.Image2D = class Image2D extends exports.Element2D {
10349
10343
  const tx = left * width * sx;
10350
10344
  const ty = top * height * sy;
10351
10345
  this.context.textureTransform = new Transform2D().scale(sx, sy).translate(tx, ty);
10352
- super._drawContent();
10346
+ this.geometry.drawRect();
10347
+ this.context.fill();
10353
10348
  }
10354
10349
  }
10355
10350
  _repaint(batchables) {
@@ -10391,7 +10386,8 @@ class TextureRect2D extends exports.Element2D {
10391
10386
  1 / width,
10392
10387
  1 / height
10393
10388
  );
10394
- super._drawContent();
10389
+ this.geometry.drawRect();
10390
+ this.context.fill();
10395
10391
  }
10396
10392
  }
10397
10393
  }
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ import { Font } from 'modern-font';
2
2
  import { AnimationItem } from 'lottie-web';
3
3
  import { AnyColor, Colord } from 'colord';
4
4
  import { Path2D, LineCap, LineJoin, LineStyle, Path2DSet } from 'modern-path2d';
5
- import { ImageFillSource, ImageFillTile, FillDeclaration, Path2DDeclaration, OutlineDeclaration, ShadowDeclaration, StyleDeclaration, ImageSource, ImageSourceRect } from 'modern-idoc';
5
+ import { ImageFillSource, ImageFillTile, ImageFillStretch, FillDeclaration, Path2DDeclaration, GeometryDeclaration, OutlineDeclaration, ShadowDeclaration, StyleDeclaration, ImageSource, ImageSourceRect } from 'modern-idoc';
6
6
  import { TextOptions, Text, MeasureResult } from 'modern-text';
7
7
  import { Node as Node$1, Direction } from 'yoga-layout/load';
8
8
 
@@ -1411,14 +1411,14 @@ interface CanvasBatchable extends Batchable2D {
1411
1411
  type: 'stroke' | 'fill';
1412
1412
  texture?: Texture2D;
1413
1413
  }
1414
- interface StrokeDraw {
1414
+ interface StrokeDraw extends Partial<CanvasBatchable> {
1415
1415
  type: 'stroke';
1416
1416
  path: Path2D;
1417
1417
  texture?: Texture2D;
1418
1418
  textureTransform?: Transform2D;
1419
1419
  style: LineStyle;
1420
1420
  }
1421
- interface FillDraw {
1421
+ interface FillDraw extends Partial<CanvasBatchable> {
1422
1422
  type: 'fill';
1423
1423
  path: Path2D;
1424
1424
  texture?: Texture2D;
@@ -1434,10 +1434,10 @@ declare class CanvasContext extends Path2D {
1434
1434
  miterLimit?: number;
1435
1435
  _defaultStyle: Texture2D<Texture2DSource>;
1436
1436
  _draws: (StrokeDraw | FillDraw)[];
1437
- stroke(): void;
1437
+ stroke(options?: Partial<StrokeDraw>): void;
1438
1438
  fillRect(x: number, y: number, width: number, height: number): void;
1439
1439
  strokeRect(x: number, y: number, width: number, height: number): void;
1440
- fill(): void;
1440
+ fill(options?: Partial<FillDraw>): void;
1441
1441
  copy(source: CanvasContext): this;
1442
1442
  reset(): this;
1443
1443
  buildUvs(start: number, vertices: number[], uvs: number[], texture?: Texture2D, textureTransform?: Transform2D): void;
@@ -1767,7 +1767,6 @@ declare class CanvasItem extends TimelineNode {
1767
1767
  protected _globalOpacity?: number;
1768
1768
  get globalOpacity(): number;
1769
1769
  protected _modulate: Color;
1770
- protected _backgroundImage?: Texture2D;
1771
1770
  context: CanvasContext;
1772
1771
  protected _resetContext: boolean;
1773
1772
  protected _redrawing: boolean;
@@ -1858,6 +1857,7 @@ declare class BaseElement2DFill extends CoreObject {
1858
1857
  dpi?: number;
1859
1858
  rotateWithShape?: boolean;
1860
1859
  tile?: ImageFillTile;
1860
+ stretch?: ImageFillStretch;
1861
1861
  protected _image?: Texture2D<ImageBitmap>;
1862
1862
  constructor(parent: BaseElement2D, properties?: Partial<BaseElement2DFillProperties>);
1863
1863
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
@@ -1867,12 +1867,7 @@ declare class BaseElement2DFill extends CoreObject {
1867
1867
  draw(): void;
1868
1868
  }
1869
1869
 
1870
- interface BaseElement2DGeometryProperties {
1871
- name?: string;
1872
- svg?: string;
1873
- viewBox?: number[];
1874
- data?: Path2DDeclaration[];
1875
- }
1870
+ type BaseElement2DGeometryProperties = GeometryDeclaration;
1876
1871
  declare class BaseElement2DGeometry extends CoreObject {
1877
1872
  parent: BaseElement2D;
1878
1873
  name?: string;
@@ -1884,6 +1879,7 @@ declare class BaseElement2DGeometry extends CoreObject {
1884
1879
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
1885
1880
  protected _updatePath2DSet(): void;
1886
1881
  draw(): void;
1882
+ drawRect(): void;
1887
1883
  }
1888
1884
 
1889
1885
  type BaseElement2DOutlineProperties = OutlineDeclaration;
@@ -1940,7 +1936,7 @@ declare class BaseElement2DText extends CoreObject {
1940
1936
  fonts?: TextOptions['fonts'];
1941
1937
  constructor(parent: BaseElement2D, properties?: Partial<BaseElement2DTextProperties>);
1942
1938
  texture: CanvasTexture;
1943
- text: Text;
1939
+ baseText: Text;
1944
1940
  measureResult?: MeasureResult;
1945
1941
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
1946
1942
  protected _updateText(): void;
@@ -2015,20 +2011,12 @@ declare class BaseElement2D extends Node2D implements Rectangulable {
2015
2011
  setProperties(properties?: Record<PropertyKey, any>): this;
2016
2012
  protected _updateStyleProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
2017
2013
  protected _updateMaskImage(): void;
2018
- protected _updateBackgroundColor(): void;
2019
- protected _updateBackgroundImage(): Promise<void>;
2020
2014
  protected _updateTransform(): void;
2021
2015
  protected _updateGlobalTransform(): void;
2022
2016
  getRect(): Rect2;
2023
2017
  protected _updateOverflow(): void;
2024
2018
  protected _draw(): void;
2025
- protected _drawBackground(): void;
2026
2019
  protected _drawContent(): void;
2027
- protected _drawBorder(): void;
2028
- protected _drawOutline(): void;
2029
- protected _drawBoundingRect(): void;
2030
- protected _fillBoundingRect(): void;
2031
- protected _strokeBoundingRect(): void;
2032
2020
  protected _repaint(batchables: CanvasBatchable[]): CanvasBatchable[];
2033
2021
  canPointerEvents(): boolean;
2034
2022
  input(event: InputEvent, key: InputEventKey): void;
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import { Font } from 'modern-font';
2
2
  import { AnimationItem } from 'lottie-web';
3
3
  import { AnyColor, Colord } from 'colord';
4
4
  import { Path2D, LineCap, LineJoin, LineStyle, Path2DSet } from 'modern-path2d';
5
- import { ImageFillSource, ImageFillTile, FillDeclaration, Path2DDeclaration, OutlineDeclaration, ShadowDeclaration, StyleDeclaration, ImageSource, ImageSourceRect } from 'modern-idoc';
5
+ import { ImageFillSource, ImageFillTile, ImageFillStretch, FillDeclaration, Path2DDeclaration, GeometryDeclaration, OutlineDeclaration, ShadowDeclaration, StyleDeclaration, ImageSource, ImageSourceRect } from 'modern-idoc';
6
6
  import { TextOptions, Text, MeasureResult } from 'modern-text';
7
7
  import { Node as Node$1, Direction } from 'yoga-layout/load';
8
8
 
@@ -1411,14 +1411,14 @@ interface CanvasBatchable extends Batchable2D {
1411
1411
  type: 'stroke' | 'fill';
1412
1412
  texture?: Texture2D;
1413
1413
  }
1414
- interface StrokeDraw {
1414
+ interface StrokeDraw extends Partial<CanvasBatchable> {
1415
1415
  type: 'stroke';
1416
1416
  path: Path2D;
1417
1417
  texture?: Texture2D;
1418
1418
  textureTransform?: Transform2D;
1419
1419
  style: LineStyle;
1420
1420
  }
1421
- interface FillDraw {
1421
+ interface FillDraw extends Partial<CanvasBatchable> {
1422
1422
  type: 'fill';
1423
1423
  path: Path2D;
1424
1424
  texture?: Texture2D;
@@ -1434,10 +1434,10 @@ declare class CanvasContext extends Path2D {
1434
1434
  miterLimit?: number;
1435
1435
  _defaultStyle: Texture2D<Texture2DSource>;
1436
1436
  _draws: (StrokeDraw | FillDraw)[];
1437
- stroke(): void;
1437
+ stroke(options?: Partial<StrokeDraw>): void;
1438
1438
  fillRect(x: number, y: number, width: number, height: number): void;
1439
1439
  strokeRect(x: number, y: number, width: number, height: number): void;
1440
- fill(): void;
1440
+ fill(options?: Partial<FillDraw>): void;
1441
1441
  copy(source: CanvasContext): this;
1442
1442
  reset(): this;
1443
1443
  buildUvs(start: number, vertices: number[], uvs: number[], texture?: Texture2D, textureTransform?: Transform2D): void;
@@ -1767,7 +1767,6 @@ declare class CanvasItem extends TimelineNode {
1767
1767
  protected _globalOpacity?: number;
1768
1768
  get globalOpacity(): number;
1769
1769
  protected _modulate: Color;
1770
- protected _backgroundImage?: Texture2D;
1771
1770
  context: CanvasContext;
1772
1771
  protected _resetContext: boolean;
1773
1772
  protected _redrawing: boolean;
@@ -1858,6 +1857,7 @@ declare class BaseElement2DFill extends CoreObject {
1858
1857
  dpi?: number;
1859
1858
  rotateWithShape?: boolean;
1860
1859
  tile?: ImageFillTile;
1860
+ stretch?: ImageFillStretch;
1861
1861
  protected _image?: Texture2D<ImageBitmap>;
1862
1862
  constructor(parent: BaseElement2D, properties?: Partial<BaseElement2DFillProperties>);
1863
1863
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
@@ -1867,12 +1867,7 @@ declare class BaseElement2DFill extends CoreObject {
1867
1867
  draw(): void;
1868
1868
  }
1869
1869
 
1870
- interface BaseElement2DGeometryProperties {
1871
- name?: string;
1872
- svg?: string;
1873
- viewBox?: number[];
1874
- data?: Path2DDeclaration[];
1875
- }
1870
+ type BaseElement2DGeometryProperties = GeometryDeclaration;
1876
1871
  declare class BaseElement2DGeometry extends CoreObject {
1877
1872
  parent: BaseElement2D;
1878
1873
  name?: string;
@@ -1884,6 +1879,7 @@ declare class BaseElement2DGeometry extends CoreObject {
1884
1879
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
1885
1880
  protected _updatePath2DSet(): void;
1886
1881
  draw(): void;
1882
+ drawRect(): void;
1887
1883
  }
1888
1884
 
1889
1885
  type BaseElement2DOutlineProperties = OutlineDeclaration;
@@ -1940,7 +1936,7 @@ declare class BaseElement2DText extends CoreObject {
1940
1936
  fonts?: TextOptions['fonts'];
1941
1937
  constructor(parent: BaseElement2D, properties?: Partial<BaseElement2DTextProperties>);
1942
1938
  texture: CanvasTexture;
1943
- text: Text;
1939
+ baseText: Text;
1944
1940
  measureResult?: MeasureResult;
1945
1941
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
1946
1942
  protected _updateText(): void;
@@ -2015,20 +2011,12 @@ declare class BaseElement2D extends Node2D implements Rectangulable {
2015
2011
  setProperties(properties?: Record<PropertyKey, any>): this;
2016
2012
  protected _updateStyleProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
2017
2013
  protected _updateMaskImage(): void;
2018
- protected _updateBackgroundColor(): void;
2019
- protected _updateBackgroundImage(): Promise<void>;
2020
2014
  protected _updateTransform(): void;
2021
2015
  protected _updateGlobalTransform(): void;
2022
2016
  getRect(): Rect2;
2023
2017
  protected _updateOverflow(): void;
2024
2018
  protected _draw(): void;
2025
- protected _drawBackground(): void;
2026
2019
  protected _drawContent(): void;
2027
- protected _drawBorder(): void;
2028
- protected _drawOutline(): void;
2029
- protected _drawBoundingRect(): void;
2030
- protected _fillBoundingRect(): void;
2031
- protected _strokeBoundingRect(): void;
2032
2020
  protected _repaint(batchables: CanvasBatchable[]): CanvasBatchable[];
2033
2021
  canPointerEvents(): boolean;
2034
2022
  input(event: InputEvent, key: InputEventKey): void;