Skip to content

Visualize Your Ideas With Code

feat(core): allow getting real size of scenes (#889)

Jacob3a6a672bed90
diff --git a/packages/core/src/scenes/GeneratorScene.ts b/packages/core/src/scenes/GeneratorScene.ts
index 9d945d7b..38d28124 100644
--- a/packages/core/src/scenes/GeneratorScene.ts
+++ b/packages/core/src/scenes/GeneratorScene.ts
@@ -292,6 +292,10 @@ export abstract class GeneratorScene<T>
return this.size;
}
+ public getRealSize(): Vector2 {
+ return this.size.mul(this.resolutionScale);
+ }
+
public isAfterTransitionIn(): boolean {
return this.state === SceneState.AfterTransitionIn;
}
diff --git a/packages/core/src/scenes/Scene.ts b/packages/core/src/scenes/Scene.ts
index 5bf34e13..0d39a13b 100644
--- a/packages/core/src/scenes/Scene.ts
+++ b/packages/core/src/scenes/Scene.ts
@@ -267,10 +267,20 @@ export interface Scene<T = unknown> {
/**
* Get the size of this scene.
*
- * Usually return `this.project.getSize()`.
+ * @remarks
+ * Usually returns `this.project.getSize()`.
*/
getSize(): Vector2;
+ /**
+ * Get the real size of this scene.
+ *
+ * @remarks
+ * Returns the size of the scene multiplied by the resolution scale.
+ * This is the actual size of the canvas onto which the scene is rendered.
+ */
+ getRealSize(): Vector2;
+
/**
* Is this scene in the {@link SceneState.AfterTransitionIn} state?
*/
@@ -304,6 +314,7 @@ export interface Scene<T = unknown> {
/**
* Is this scene cached?
*
+ * @remarks
* Used only by {@link GeneratorScene}. Seeking through a project that
* contains at least one uncached scene will log a warning to the console.
*