Less rigid drawing lines in Hopscotch! Replace the regular “Draw With a Pen” to smoother lines! LEVEL UP YOUR DRAWING PAD!

drawingpad

#1

To cut to the chase, here’s the program what everyone draws in—


And here’s the one you should try—

Much smoother, right? These lines have been drawn with the same velocity, which means I didn’t take my time to try to draw the smoother one.
Check out the code here! (Courtesy of @NindroidGames)

How it works—
I don’t know. It’s probably because more clones make things smoother.

Thanks @Petrichor and @William04GamerA!
See post 12, 17-18 for more information

Level up your drawing pad today! Smooth lines are your friends!


#2

But wouldn’t more clones lower the FPS?


#3

Invisible clones would hardly do a thing…


#4

@sophia71205 @CreationsOfaNoob
Framerate of invisible clones


#5

Still, wouldn’t it be easier to:


#6

Does it have the same effect as above? ^^^^^^^^


#7

I mean, idk what velocity or width you used, so here try it:


#8

I tried it out and that’s what happened
Most drawings on HS are quick, so this program is okay for those types of drawings.


#9

That one is good. However, the lag in recent projects makes it so that the lines are rigid. Oof modern drafts


#10

The not a clone thing could be done without a check once if.

That would cause the first image.

I’ll try to find something easier, one second.

EDIT: Okay, this is easier. Basically the same, but less laggy. There’s one problem, but it’s probably easy to fix.
https://c.gethopscotch.com/p/zil50z6mm

EDIT TWO: fixed it


#11

I see the problem, but i don’t know how to fix it either :man_shrugging:


#12

I was right

It was easy.

Just change the repeat two to a repeat four. It seems to make it smoother also.


#13

Thanks! (Poop I take all your ideas sorry)


#14

If you edit the JSON you can make everything quick even with clones except idk how to do that. There’s a tutorial on it around here somewhere by Thin Buffalo Sr. or COAN


#15

Thanks for the cool code! Is this code better than the first one though?


#16

Yeah I think so


#17
Tagging those who commented above or liked the original post:

@DECODECO
@William04GamerA
@JonnyGamer
@Petrichor
@sophia71205
@Kitty4Alt
@HorseLove347
@Chibimeringue
@Kayro
@Autumn_Leaves
@ilovechickens
@ThatOneBiKid
@Gobli09
@Jedi4Jesus
@Madsie05
@DaughterOfHades

I thought you might like to know why this project works and how to accomplish the same effect easier

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”

DECODECO/NindroidGames’ code is creating a bunch of clones that are all trying to draw so, effectively, the last touch locations are getting updated and a Draw a Trail gets run every frame. This doubles the number of drawing segments in the line. However, once we understand why the code works we can create the same effect in a much simpler way.

This can be done 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 :smiley:


#18

I should add this 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. There’s just some wierd nuisances to how the Hopscotch player runs your code :roll_eyes:


#19

That’s really helpful, thanks!


#20

I don’t see a difference between We2Fd’s Pad and this one that Nindroid and DecodeCo made

But I’m on a phone so I can’t tell