From 0cf99cf95d098392d7d1943aac37b12bd831a1d9 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 24 Aug 2023 18:22:20 +0200 Subject: Add a Viewport method to get automatically computed 2D stretch transform `Viewport.get_stretch_transform()` returns the automatically computed 2D stretch transform. Combined with `Transform2D.get_scale()`, this is useful when using the `canvas_items` stretch mode in a project. There are many situations where knowing this factor is useful: - Divide Camera2D zoom to keep the size of the 2D game world identical regardless of the 2D scale factor (so that UI elements can still be scaled). - Make certain controls always drawn at 1:1 scale (e.g. for the crosshair in a FPS). This is done by dividing the Control node's scale by the scale factor. --- doc/classes/Window.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc/classes/Window.xml') diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml index 02110f0162..1a4c25b916 100644 --- a/doc/classes/Window.xml +++ b/doc/classes/Window.xml @@ -572,7 +572,7 @@ Specifies how the content's aspect behaves when the [Window] is resized. The base aspect is determined by [member content_scale_size]. - Specifies the base scale of [Window]'s content when its [member size] is equal to [member content_scale_size]. + Specifies the base scale of [Window]'s content when its [member size] is equal to [member content_scale_size]. See also [method Viewport.get_stretch_transform]. Specifies how the content is scaled when the [Window] is resized. -- cgit v1.2.3