# Paste a Sprite on another Sprite

We've just made another minor Snap! release - v5.1.0 - that features, among other things, a new block in the "pen" category called "paste on _":

"Paste" is similar to the "stamp" block, but instead of leaving a print on the stage's pen trails layer the new "paste" block leaves a print on another sprite. It does so by creating a copy of the sprite's costume with a print of the source sprite on it. To clear the pastings you can let the sprite switch back to the original costume (or to another one).

This opens up a variety of fun ideas to try, and I've been having a blast playing with it already. It's especially interesting when both sprites move and turn independently:

It also opens up new twists to turtle geometry. For example, instead of moving and turning a pen sprite you can now move the sprite and turn the background, like this:

But you can also use the "paste" block for creating your own jigsaw puzzles and for overlaying versions of pictures and letting the user "slide" them:

We can't wait to see what you'll build with this new "paste" block!

Polka Dots were pasted on a little elephant, using your new super-fun block, in order to recreate this picture by artist Moses Sia from Singapore, and animate the dots - see ProjectName=Elephant_with_Polka_Dots_pasted It would be really fun to have an ability to take into the account the graphic effects applied to the (pasted) sprite built in the new block or at least to apply for example ghost effect after the dots were pasted on the costume. See ProjectName=Paste_on_with_graphic_effects_request for illustration of what I mean.

Nice, I love the Polka-Dotted Elephant! Yes, that's what we had in mind
I agree it would be nice to keep the graphic effects of the source, but I found it impossible to reverse them so the end up being what you want them to be when you end up applying the target's effects, too. But maybe we'll end up finding a way...

Hi @jens! It's a very good feature that opens way to many new ideas! But it is somewhat restricted by two things:

1. pasting cannot change the size of the sprite being printed on. And it's ok.
2. pasting do not change transparent pixels parts of the sprite being printed on. And this restriction is quite disappointing. It would be great two have the ability to fill transparent parts of the sprite with pasting another sprite onto them WITHIN initial sprite borders! Or maybe it can be a setting of the "paste on" block: affect transparent pixels or don't affect. Is it possible to add this feature?
Now I'm forced to edit directly "pixels of costume" list, and it is sooooo slooooow when you need to alter a lot of pixels.

Pavel B.

Could you post a link to an example of what your trying to do?

It may be possible to speed it up using a hyperblocks approach

Ok. Here is the example: https://snap.berkeley.edu/snap/snap.html#present:Username=pavelbel&ProjectName=holes%20demo
Click the green flag and then click anywhere on the brick wall. You will see holes appearing in it. You can even see background throught them. I do it by manual editing of brick wall's pixels - setting some of them to be transparent.

I don't know why i had to do snap forks, I guess just to try it out..

I couldn't come up with a hyperblocks method but modified a project from the recent Snap! course to give a low code similar effect

Brilliant idea of using background image clipped by sprite used as mask
It can be further simplified to stamping without clones.
BTW: there is no need to show sprite before stamping/pasting.

The paste on block doesn't seem to be affected by the color graphic effect.

Yes, that's right. paste disregards graphic effects both on the pasted and the pasted-on sprite. it does take into consideration (relative) size, position and rotation, which lets you do all kinds of interesting effects yourself. And you can also paste a sprite onto all clones of another sprite simply by choosing the original's name. That way you can create a multi-part jigsaw-puzzle or a swarm-picture in a single pass. Example:

Oh yes, that's a good idea for making visual "holes", thank you! But it wasn't my real goal It was just a part of a more complex task. Here is another example:

Move mouse to aim, press SPACE to fire. You see here: cannonballs damage the terrain. I have a terrain sprite and a "sky" sprite to paste on the terrain to emulate shell craters, similarily to what you do. Now I use "touching color" sensor to detect when and where a cannonball hits the terrain. This approach has two problems:
1. I want the terrain to have a texture. But now it must be of one solid color to use "touching color" sensor correctly. It also implies that the background picture should not have this color on it.
2. "touching color" sensor is quite slow.

That's why I'm looking forward to use "touching sprite" instead, because it solves both issues. And that's why I try to make some parts of the terrain sprite really transparent - so that "touching sprite (= terrain)" sensor can return "false" when a cannonball is over these transparent parts.

So I end up manually altering (i.e. setting the alpha value to zero of) terrain's pixels near the impact point, and it's quite slow. It would be great to do this with some kind of "paste on" blocks. Is it possible, @jens?

OMG, this project is awesome! Would you mind publishing it so I can feature it?

maybe you could try pasting another sprite whose costume is almost-fully-transparent on it, with a very low alpha value? Oh, wait, no. Pasting only adds, never subtracts.

Oh... For me it's just a draft to put the basic mechanics right... But if you think it's worth featuring, I won't mind.