Discuss Scratch

-Rex-
Scratcher
500+ posts

Save Pen Strokes

This suggestion would allow pen actions (sprite movements, pen down/up, pen size, perhaps pen color) to be stored in a variable so that they can be quickly repeated elsewhere.

All blocks should work like normal (including the pen blocks, so that the strokes are drawn on screen like normal) so that variables and if-blocks can affect what pen strokes are stored. This would be different from using a custom block, since variables are re-read and if statements are re-evaluated every time they are executed, which would not be the case with this suggestion.
save pen strokes to [drawing v] { 
go to x: (0) y: (0)
pen down
move (10) steps
...
pen up
} :: pen
draw [drawing v] with direction (90 v) and size (50) % :: pen // the starting point is the same as the sprite's current position
I think the “variables” for pen strokes could be a new data, in addition to variables and lists.

Example usage:
save pen strokes to [drawing v] {
repeat until (key [space v] pressed? :: boolean)
wait until <mouse down?>
go to [mouse-pointer v]
pen down
repeat until (not (mouse down? :: boolean) :: boolean)
go to [mouse-pointer v]
end
pen up
end
} :: pen
wait until (not (key [space v] pressed? :: boolean) :: boolean)
... // draw it wherever you want
Data size might be a problem if used this way, though.

Last edited by -Rex- (March 17, 2019 22:10:21)

Flipped_
Scratcher
500+ posts

Save Pen Strokes

I think that you could accomplish exactly this with My Blocks. What makes this feature different from My Blocks?

☄️ Hey! I'm Flipped_. ☄️

Here, you can sit down in that chair over there. No no, that one. The other
one is reserved for my pet coelacanth.
I guess we wait now. Feel free to drink some orange juice
in the meantime.
———————————————
CKCG
Scratcher
100+ posts

Save Pen Strokes

Can't this be done with custom functions?
define Pen1
pen strokes here :: #808080

when green flag clicked
Pen1 :: custom
No support.

edit: lol while i was typing this out i got sniped

Last edited by CKCG (March 17, 2019 21:54:56)


I'm no longer active on these forums.
-Rex-
Scratcher
500+ posts

Save Pen Strokes

Flipped_ wrote:

I think that you could accomplish exactly this with My Blocks. What makes this feature different from My Blocks?
This would theoretically be simpler and faster if you want to store dynamically-generated data.
-Rex-
Scratcher
500+ posts

Save Pen Strokes

CKCG wrote:

Can't this be done with custom functions?
define Pen1
pen strokes here :: #808080

when green flag clicked
Pen1 :: custom
No support.

edit: lol while i was typing this out i got sniped
The problem is that if you want to store pen strokes that are dynamically-generated, you have to implement some way to interpret a list or string, which many Scratchers may not want to do.
CKCG
Scratcher
100+ posts

Save Pen Strokes

-Rex- wrote:

CKCG wrote:

Can't this be done with custom functions?
define Pen1
pen strokes here :: #808080

when green flag clicked
Pen1 :: custom
No support.

edit: lol while i was typing this out i got sniped
The problem is that if you want to store pen strokes that are dynamically-generated, you have to implement some way to interpret a list or string, which many Scratchers may not want to do.
What do you mean by dynamically-generated pen strokes?

I'm no longer active on these forums.
Jonathan50
Scratcher
1000+ posts

Save Pen Strokes

Do you mean in an ordinary variable? Would the watcher become blank?

(Snap! has first-class procedures which make this easy. There is an example project called Vee which you can find by going File->Open…->Examples.)

Last edited by Jonathan50 (March 19, 2019 05:29:38)


Not yet a Knight of the Mu Calculus.
-Rex-
Scratcher
500+ posts

Save Pen Strokes

Jonathan50 wrote:

Do you mean in an ordinary variable? Would the watcher become blank?

(Snap! has first-class procedures which make this easy. There is an example project called Vee which you can find by going File->Open…->Examples.)
Seeing as how even lists aren’t first-class, I don’t think a new first-class data type should be added. I also don’t think regular variables should be used.
-Snipet-
Scratcher
500+ posts

Save Pen Strokes

This would vastly simplify PTEs. Support.

website =)
Blasted little 60 second rule…
Jonathan50
Scratcher
1000+ posts

Save Pen Strokes

-Rex- wrote:

Seeing as how even lists aren’t first-class, I don’t think a new first-class data type should be added. I also don’t think regular variables should be used.
Okay. But first-class procedures are much more general, for example, if you wanted to use this to make a PTE like -Snipet- mentioned, unless the Scratch Team were to allow dropping reports into the dropdowns, you'd need an IF block for every possible character, whereas with first-class procedures you could use the Unicode codepoint as an index into a list of scripts for drawing characters. First-class procedures even make message passing simple (no broadcasts or clone IDs.) However, your example use case would be much less clear.

Not yet a Knight of the Mu Calculus.
-Rex-
Scratcher
500+ posts

Save Pen Strokes

Jonathan50 wrote:

-Rex- wrote:

Seeing as how even lists aren’t first-class, I don’t think a new first-class data type should be added. I also don’t think regular variables should be used.
Okay. But first-class procedures are much more general, for example, if you wanted to use this to make a PTE like -Snipet- mentioned, unless the Scratch Team were to allow dropping reports into the dropdowns, you'd need an IF block for every possible character, whereas with first-class procedures you could use the Unicode codepoint as an index into a list of scripts for drawing characters. First-class procedures even make message passing simple (no broadcasts or clone IDs.) However, your example use case would be much less clear.
I know what first-class procedures are. However, I don't think the Scratch Team would agree to implement it in Scratch.
LegoManiac04
Scratcher
1000+ posts

Save Pen Strokes

This can be kind of done with lists. It's something that I'm still working on, but if you want to see what I did, look here: https://scratch.mit.edu/projects/292671535/editor

But, I can see how this could be very useful, so Support.

Last edited by LegoManiac04 (March 20, 2019 22:56:13)


-Rex-
Scratcher
500+ posts

Save Pen Strokes

LegoManiac04 wrote:

This can be kind of done with lists. It's something that I'm still working on, but if you want to see what I did, look here: https://scratch.mit.edu/projects/292671535/editor

But, I can see how this could be very useful, so Support.
I know it can be done with lists, but my point is that many Scratchers may not want to use lists for something like this.

Powered by DjangoBB