modern-canvas 0.5.0 → 0.5.2

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
@@ -4300,7 +4300,7 @@ function parseCSSFilter(filter) {
4300
4300
 
4301
4301
  function parseCSSTransform(transform, width, height, output = new Transform2D()) {
4302
4302
  transform = !transform || transform === "none" ? "" : transform;
4303
- parseCssFunctions(transform, { width, height }).forEach(({ name, args }) => {
4303
+ parseCssFunctions(transform, { width, height }).reverse().forEach(({ name, args }) => {
4304
4304
  const values = args.map((arg) => arg.normalizedIntValue);
4305
4305
  switch (name) {
4306
4306
  case "translate":
@@ -9318,7 +9318,6 @@ class BaseElement2DText extends CoreObject {
9318
9318
  this.parent = parent;
9319
9319
  }
9320
9320
  base = new modernText.Text();
9321
- texture = new CanvasTexture();
9322
9321
  measureResult;
9323
9322
  setProperties(properties) {
9324
9323
  return super.setProperties(
@@ -9357,29 +9356,23 @@ class BaseElement2DText extends CoreObject {
9357
9356
  }
9358
9357
  canDraw() {
9359
9358
  return Boolean(
9360
- this.enabled && !/^\s*$/.test(this.base.toString()) && this.texture?.valid
9359
+ this.enabled && !/^\s*$/.test(this.base.toString())
9361
9360
  );
9362
9361
  }
9363
9362
  draw() {
9364
- this.base.render({
9365
- pixelRatio: this.texture.pixelRatio,
9366
- view: this.texture.source
9367
- });
9368
- this.texture.requestUpload();
9369
- const textWidth = this.measureResult?.boundingBox.width ?? this.parent.size.width;
9370
- const textHeight = this.measureResult?.boundingBox.height ?? this.parent.size.height;
9371
9363
  const ctx = this.parent.context;
9372
- ctx.fillStyle = this.texture;
9373
- ctx.uvTransform = new Transform2D().scale(1 / textWidth, 1 / textHeight);
9374
- ctx.vertTransform = () => {
9375
- const parent = this.parent;
9376
- const origin = parent.getTransformOrigin();
9377
- return new Transform2D().translate(-origin.x, -origin.y).scale(
9378
- parent.globalScale.x > 0 ? 1 : -1,
9379
- parent.globalScale.y > 0 ? 1 : -1
9380
- ).translate(origin.x, origin.y);
9381
- };
9382
- ctx.fill();
9364
+ this.base.update();
9365
+ this.base.paragraphs.forEach((p) => {
9366
+ p.fragments.forEach((f) => {
9367
+ f.characters.forEach((c) => {
9368
+ ctx.fillStyle = c.computedStyle.color;
9369
+ ctx.addPath(c.path);
9370
+ ctx.style.fillRule = "evenodd";
9371
+ ctx.closePath();
9372
+ ctx.fill();
9373
+ });
9374
+ });
9375
+ });
9383
9376
  }
9384
9377
  }
9385
9378
  __decorateClass$o([
@@ -9790,7 +9783,6 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
9790
9783
  }
9791
9784
  if (this._text.canDraw()) {
9792
9785
  this._tree?.log(this.name, "draw text");
9793
- this._shape.drawRect();
9794
9786
  this._text.draw();
9795
9787
  }
9796
9788
  this._drawContent();
package/dist/index.d.cts CHANGED
@@ -1992,7 +1992,6 @@ declare class BaseElement2DText extends CoreObject {
1992
1992
  fonts?: Text['fonts'];
1993
1993
  constructor(parent: BaseElement2D);
1994
1994
  base: Text;
1995
- texture: CanvasTexture;
1996
1995
  measureResult?: MeasureResult;
1997
1996
  setProperties(properties?: Text$1): this;
1998
1997
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
package/dist/index.d.mts CHANGED
@@ -1992,7 +1992,6 @@ declare class BaseElement2DText extends CoreObject {
1992
1992
  fonts?: Text['fonts'];
1993
1993
  constructor(parent: BaseElement2D);
1994
1994
  base: Text;
1995
- texture: CanvasTexture;
1996
1995
  measureResult?: MeasureResult;
1997
1996
  setProperties(properties?: Text$1): this;
1998
1997
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
package/dist/index.d.ts CHANGED
@@ -1992,7 +1992,6 @@ declare class BaseElement2DText extends CoreObject {
1992
1992
  fonts?: Text['fonts'];
1993
1993
  constructor(parent: BaseElement2D);
1994
1994
  base: Text;
1995
- texture: CanvasTexture;
1996
1995
  measureResult?: MeasureResult;
1997
1996
  setProperties(properties?: Text$1): this;
1998
1997
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;