Closed Okay6 closed 2 months ago
Describe the bug
To Reproduce
Screenshots
Additional context
My solution
styles.width = changed.width styles.height = changed.height
.... if (this._scale instanceof Vector) { changed.width *= this._scale.x; changed.height *= this._scale.y; } else { changed.width *= this._scale; changed.height *= this._scale; } // added to keep same width and height between pattern and image styles.width = changed.width styles.height = changed.height ....
I tested modified code in my local environment, it works well
import Two from "../two.js/src/two"; const two = new Two({ type: Two.Types.svg, fullscreen: true, autostart: true }).appendTo(document.body); const rectangle = new Two.Rectangle(two.width / 2, two.height / 2, 200, 200); rectangle.fill = new Two.Texture('/texture.jpg', onLoad); rectangle.noStroke() rectangle.position.x = 200 two.add(rectangle); function onLoad() { const image = rectangle.fill.image; const desiredWidth = rectangle.width; const desiredHeight = rectangle.height; const sx = desiredWidth / image.width; const sy = desiredHeight / image.height; rectangle.fill.scale = new Two.Vector(sx, sy); }
Ah, Thank you! I will patch this.
Okay, Two.js version 0.8.14 addresses this issue. Thank you again!
Cool!
Describe the bug
To Reproduce
Screenshots
Additional context
My solution
styles.width = changed.width styles.height = changed.height
after svg.js#line 1073 look like this:I tested modified code in my local environment, it works well