feat(ui): restore document size overlay renderer

This commit is contained in:
psychedelicious 2024-07-08 19:16:05 +10:00
parent 8e8c255f3f
commit 118278b372

View File

@ -31,29 +31,23 @@ export class CanvasDocumentSizeOverlay {
} }
render() { render() {
return; const document = this.manager.stateApi.getDocument();
// const document = this.manager.stateApi.getDocument(); this.group.zIndex(0);
// this.group.zIndex(0);
// const x = this.manager.stage.x(); const x = this.manager.stage.x();
// const y = this.manager.stage.y(); const y = this.manager.stage.y();
// const width = this.manager.stage.width(); const width = this.manager.stage.width();
// const height = this.manager.stage.height(); const height = this.manager.stage.height();
// const scale = this.manager.stage.scaleX(); const scale = this.manager.stage.scaleX();
// this.outerRect.setAttrs({ this.outerRect.setAttrs({
// offsetX: x / scale, offsetX: x / scale,
// offsetY: y / scale, offsetY: y / scale,
// width: width / scale, width: width / scale,
// height: height / scale, height: height / scale,
// }); });
// this.innerRect.setAttrs({ this.innerRect.setAttrs(document.rect);
// x: 0,
// y: 0,
// width: document.width,
// height: document.height,
// });
} }
fitToStage() { fitToStage() {
@ -62,8 +56,8 @@ export class CanvasDocumentSizeOverlay {
// Fit & center the document on the stage // Fit & center the document on the stage
const width = this.manager.stage.width(); const width = this.manager.stage.width();
const height = this.manager.stage.height(); const height = this.manager.stage.height();
const docWidthWithBuffer = document.width + this.padding * 2; const docWidthWithBuffer = document.rect.width + this.padding * 2;
const docHeightWithBuffer = document.height + this.padding * 2; const docHeightWithBuffer = document.rect.height + this.padding * 2;
const scale = Math.min(Math.min(width / docWidthWithBuffer, height / docHeightWithBuffer), 1); const scale = Math.min(Math.min(width / docWidthWithBuffer, height / docHeightWithBuffer), 1);
const x = (width - docWidthWithBuffer * scale) / 2 + this.padding * scale; const x = (width - docWidthWithBuffer * scale) / 2 + this.padding * scale;
const y = (height - docHeightWithBuffer * scale) / 2 + this.padding * scale; const y = (height - docHeightWithBuffer * scale) / 2 + this.padding * scale;