From f1fdb92d7e49fdc8809fba1271498c0456f60fdc Mon Sep 17 00:00:00 2001 From: Maxime Lapointe Date: Sun, 5 Sep 2021 12:02:01 -0400 Subject: [PATCH] Reword intro do custom_drawing_in_2d The wording felt very off from the other tutorials. This bring it more in line, using a simple 'Introduction' as first section. --- tutorials/2d/custom_drawing_in_2d.rst | 34 ++++++++++++--------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/tutorials/2d/custom_drawing_in_2d.rst b/tutorials/2d/custom_drawing_in_2d.rst index eaa41ebd9..733c07c08 100644 --- a/tutorials/2d/custom_drawing_in_2d.rst +++ b/tutorials/2d/custom_drawing_in_2d.rst @@ -3,8 +3,8 @@ Custom drawing in 2D ==================== -Why? ----- +Introduction +------------ Godot has nodes to draw sprites, polygons, particles, and all sorts of stuff. For most cases, this is enough; but not always. Before crying in fear, @@ -13,26 +13,22 @@ it would be good to know that it is possible to easily make any 2D node (be it :ref:`Control ` or :ref:`Node2D ` based) draw custom commands. It is *really* easy to do it, too. -But... ------- +Custom drawing in a 2D node is *really* useful. Here are some use cases: -Custom drawing manually in a node is *really* useful. Here are some -examples why: - -- Drawing shapes or logic that is not handled by nodes (example: making - a node that draws a circle, an image with trails, a special kind of - animated polygon, etc). -- Visualizations that are not that compatible with nodes: (example: a - tetris board). The tetris example uses a custom draw function to draw - the blocks. +- Drawing shapes or logic that existing nodes can't do, such as an image + with trails or a special animated polygon. +- Visualizations that are not that compatible with nodes, such as a + tetris board. (The tetris example uses a custom draw function to draw + the blocks.) - Drawing a large number of simple objects. Custom drawing avoids the - overhead of using nodes which makes it less memory intensive and - potentially faster. + overhead of using a large number of nodes, possibly lowering memory + usage and improving performance. - Making a custom UI control. There are plenty of controls available, - but it's easy to run into the need to make a new, custom one. + but when you have unusual needs, you will likely need a custom + control. -OK, how? --------- +Drawing +------- Add a script to any :ref:`CanvasItem ` derived node, like :ref:`Control ` or @@ -64,7 +60,7 @@ The ``_draw()`` function is only called once, and then the draw commands are cached and remembered, so further calls are unnecessary. If re-drawing is required because a state or something else changed, -simply call :ref:`CanvasItem.update() ` +call :ref:`CanvasItem.update() ` in that same node and a new ``_draw()`` call will happen. Here is a little more complex example, a texture variable that will be