[Tutorial] Simple Improvement for Drawing Pads (HD Draw: 2X the Segments)


Reposting/reformatting as a stand-alone tutorial since it was in a topic that was deprecated

First, you have to understand that the normal code for a pen only draws every other frame . That’s because the When :iphone:Is Pressed rule has a null frame before it will execute again. Meaning, it waits 1 frame before it will start over. That in turn means the Draw a Trail only runs at 30 FPS instead of 60 FPS

Here’s an example project I made a while back to demonstrate this “bug”

Twice the standard number of curves can be accomplished with 1 object (no clones) and only a simple modification of the usual pen code like this:

First, we add 2 rules so we get a variable that is set to 1 when the device is pressed and 0 when it isn’t pressed. The wait block is because the conditional rule doesn’t have the null frame of the When Pressed rule so the wait block keeps the 2 rules synchronized,


Then we add the usual When :iphone:Is Tapped


Last, and here’s the key part, we modify the usual When :iphone:Is Pressed so it doesn’t leave the rule until the device isn’t pressed. We do this with recursion (notice the custom ability refers to itself). The Check If just checks the Pressed variable and loops within the HDdraw custom ability instead of looping the When :iphone:Is Pressed rule. This avoids the null frame and lets the Draw a Trail run at 60 FPS


Here’s the HDdraw code in an example project:

Happy coding :grinning:


I should add that doing this


instead of the When :iphone:Is Pressed with recursion should logically work and be even simpler, but it doesn’t. I believe having Draw a Trail as the last block in a conditional rule also creates a null frame.


woah this is awesome, thanks!


:clap: :clap: Bravo m8

Very helpful




What is HD draw?
How does it differ?


It draws a line segment twice as often as the standard method of drawing like a pen.