Comparing version 0.7.29 to 0.7.30
@@ -277,6 +277,2 @@ import * as rc from './rive_canvas.js'; | ||
/** | ||
* Clears the canvas | ||
*/ | ||
private clearCanvas; | ||
/** | ||
* Align the renderer | ||
@@ -283,0 +279,0 @@ */ |
{ | ||
"name": "rive-js", | ||
"version": "0.7.29", | ||
"version": "0.7.30", | ||
"description": "Rive's web api.", | ||
@@ -5,0 +5,0 @@ "main": "dist/rive.dev.js", |
@@ -962,3 +962,2 @@ import * as rc from './rive_canvas.js'; | ||
this.layout = params.layout ?? new Layout(); | ||
this._updateLayout = true; | ||
@@ -1208,5 +1207,2 @@ // Fetch the 2d context from the canvas | ||
// Clear the canvas for the next frame | ||
this.clearCanvas(); | ||
this.artboard.draw(this.renderer); | ||
@@ -1238,40 +1234,23 @@ | ||
/** | ||
* Clears the canvas | ||
*/ | ||
private clearCanvas(): void { | ||
// Preserve the current transform matrix | ||
this.ctx.save(); | ||
// Use the identity matrix while clearing the canvas to ensure whole canvas is cleared | ||
this.ctx.setTransform(1, 0, 0, 1, 0, 0); | ||
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.width); | ||
// Restore transform matrix | ||
this.ctx.restore(); | ||
} | ||
/** | ||
* Align the renderer | ||
*/ | ||
private alignRenderer(): void { | ||
// Update the renderer alignment if necessary | ||
if (this._updateLayout) { | ||
// Restore from previous save in case a previous align occurred | ||
this.ctx.restore(); | ||
// Canvas must be wiped to prevent artifacts | ||
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); | ||
// Now save so that future changes to align can restore | ||
this.ctx.save(); | ||
// Align things up safe in the knowledge we can restore if changed | ||
this.renderer.align( | ||
this._layout.runtimeFit(this.runtime), | ||
this._layout.runtimeAlignment(this.runtime), | ||
{ | ||
minX: this._layout.minX, | ||
minY: this._layout.minY, | ||
maxX: this._layout.maxX, | ||
maxY: this._layout.maxY | ||
}, | ||
this.artboard.bounds | ||
); | ||
this._updateLayout = false; | ||
} | ||
// Restore from previous save in case a previous align occurred | ||
this.ctx.restore(); | ||
// Canvas must be wiped to prevent artifacts | ||
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); | ||
// Now save so that future changes to align can restore | ||
this.ctx.save(); | ||
// Align things up safe in the knowledge we can restore if changed | ||
this.renderer.align( | ||
this._layout.runtimeFit(this.runtime), | ||
this._layout.runtimeAlignment(this.runtime), | ||
{ | ||
minX: this._layout.minX, | ||
minY: this._layout.minY, | ||
maxX: this._layout.maxX, | ||
maxY: this._layout.maxY | ||
}, | ||
this.artboard.bounds | ||
); | ||
} | ||
@@ -1378,4 +1357,2 @@ | ||
this.stop(); | ||
// Update the layout to account for new renderer | ||
this._updateLayout = true; | ||
// Reinitialize | ||
@@ -1388,3 +1365,2 @@ this.init(params); | ||
this._layout = layout; | ||
this._updateLayout = true; | ||
// If the maxX or maxY are 0, then set them to the canvas width and height | ||
@@ -1419,3 +1395,2 @@ if (!layout.maxX || !layout.maxY) { | ||
}); | ||
this._updateLayout = true; | ||
} | ||
@@ -1422,0 +1397,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
2478454
16921