Resizing costume images

Hey everyone, I'm trying to resize the image generated by the pen trails. I am able to download the image as a png, but I was wondering whether there was any way to modify the costume within Snap! itself? I'm looking to scale the pen trails down to 28x28, specifically. Thanks!

1)wear the costume of your pentrails
2)clear the pentrails
3)reduce your size until you reach 28x28
5) new pentrails are now 28*28

i don't about the image definition but it can work...

Even simpler:

(new costume ([pixels v] of costume (pen trails::pen)::looks) width (28 v) height (28 v)::looks)

good idea !

that doesn't actually resize the image, It just reads the image as if it's that size, which also ruins the image.

@loucheman does have a simple solution that works, but not with the best quality,

but what does work, is using the stretch block.

Yes, I see... How would you convert the list of PIXELS OF COSTUME back to its original shape?

Literally working on this concept right now, that's why I came to the forums! Do you know if stretching a pen costume makes a new one every time I stretch it? Or does it just modify the current one? I wanted to make a stretchy costume out of pen (got the pen to costume part down)

the stretch costume block just reports a costume. It does not replace a costume, and it doesn't add the costume to the costumes tab. To add or replace a costume in the costumes tab using code, just modify the untitled script pic list (it'll have items in it if you have costumes, I just don't have any costumes in the sprite)

I mean setting costume to stretch. I actually found the answer myself a bit ago and then abandoned the use of it because you can't set it to a value in a loop because it keeps taking the length of itself and halving it. I thought it was a "set" thing, not something that permanently altered the costume. I'm sure I could find a work-around but ended up just making a draw back and forth pen line that constantly deletes itself. Trying to fix the lag on that now. Anyway, thank you for trying to help! I should have tested it myself before clogging up the forum, sorry about that!

Well I unabandoned it because of the pen lag and made a workaround that probably isn't even considered a work around: making the stretch script apply to the original costume rather than the current costume, and that worked. The original problem I had with that before is because the costume didn't exist before the script ran (because of "set costume to pen trails") but I set a script variable to the pen costume before the loop and it did what I wanted it to then.

Edit: These are the blocks I made that are related to pen costumes and resizing them. Not necessarily for the one who posted the topic but for anyone who sees the topic and wants to use them. I am new to the forums and the editor, so if I am supposed to make a new topic under "share projects" please let me know :slight_smile: Here are the blocks:


Pengine animator script pic (7)
Pengine animator script pic (8)
Pengine animator script pic (9)
Pengine animator script pic (10)

<blocks app="Snap! 6," version="1"><block-definition s="X-Midpoint of %&apos;Sprite1&apos; and %&apos;Sprite 2&apos;" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%obj"></input><input type="%obj"></input></inputs><script><block s="doDeclareVariables"><list><l>x</l></list></block><block s="doSetVar"><l>x</l><block s="reportQuotient"><block s="reportSum"><block s="reportAttributeOf"><l><option>x position</option></l><block var="Sprite1"/></block><block s="reportAttributeOf"><l><option>x position</option></l><block var="Sprite 2"/></block></block><l>2</l></block></block><block s="doReport"><block var="x"/></block></script></block-definition><block-definition s="Y-Midpoint of %&apos;Sprite1&apos; and %&apos;Sprite 2&apos;" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%obj"></input><input type="%obj"></input></inputs><script><block s="doDeclareVariables"><list><l>y</l></list></block><block s="doSetVar"><l>y</l><block s="reportQuotient"><block s="reportSum"><block s="reportAttributeOf"><l><option>y position</option></l><block var="Sprite1"/></block><block s="reportAttributeOf"><l><option>y position</option></l><block var="Sprite 2"/></block></block><l>2</l></block></block><block s="doReport"><block var="y"/></block></script></block-definition><block-definition s="Stretchy costume | Point 1: %&apos;Loc.1&apos; Point 2: %&apos;Loc.2&apos; | Costume: %&apos;Costume&apos;" type="reporter" category="looks"><header></header><code></code><translations></translations><inputs><input type="%obj"></input><input type="%obj"></input><input type="%s"><options>§_costumesMenu</options></input></inputs><script><block s="doReport"><block s="reportNewCostumeStretched"><block var="Costume"/><block s="reportProduct"><block s="reportQuotient"><custom-block s="$arrowRightThin Distance between %obj and %obj"><block var="Loc.1"/><block var="Loc.2"/></custom-block><block s="reportGetImageAttribute"><l><option>width</option></l><block var="Costume"/></block></block><l>100</l></block><l>100</l></block></block></script></block-definition><block-definition s="$arrowRightThin Distance between %&apos;Sprite one&apos; and %&apos;Sprite two&apos;" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%obj"></input><input type="%obj"></input></inputs><script><block s="doDeclareVariables"><list><l>x1</l><l>x2</l><l>y1</l><l>y2</l></list></block><block s="doSetVar"><l>x1</l><block s="reportAttributeOf"><l><option>x position</option></l><block var="Sprite one"/></block></block><block s="doSetVar"><l>y1</l><block s="reportAttributeOf"><l><option>y position</option></l><block var="Sprite one"/></block></block><block s="doSetVar"><l>x2</l><block s="reportAttributeOf"><l><option>x position</option></l><block var="Sprite two"/></block></block><block s="doSetVar"><l>y2</l><block s="reportAttributeOf"><l><option>y position</option></l><block var="Sprite two"/></block></block><block s="doReport"><block s="reportMonadic"><l><option>sqrt</option></l><block s="reportSum"><block s="reportPower"><block s="reportDifference"><block var="x1"/><block var="x2"/></block><l>2</l></block><block s="reportPower"><block s="reportDifference"><block var="y1"/><block var="y2"/></block><l>2</l></block></block></block></block></script></block-definition></blocks>

Example usage of these custom blocks

Pengine animator script pic (11)

"Line" block
Used to make a line between two "control points" (draggable sprites).

<blocks app="Snap! 6," version="1"><block-definition s="Line %&apos;Point ONE&apos; %&apos;Point TWO&apos;" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input></inputs><script><block s="doDeclareVariables"><list><l>costume</l><l>Point one</l><l>Point two</l></list></block><block s="doWarp"><script><block s="doSetVar"><l>Point one</l><block var="Point ONE"/></block><block s="doSetVar"><l>Point two</l><block var="Point TWO"/></block><block s="setColor"><color>0,2,18,1</color></block><block s="clear"></block><block s="setSize"><l>5</l></block><block s="doGotoObject"><block var="Point one"/></block><block s="down"></block><block s="changeXPosition"><block s="reportAskFor"><block var="Point one"/><block s="reifyReporter"><autolambda><block s="reportRelationTo"><l><option>distance</option></l><block var="Point two"/></block></autolambda><list></list></block><list></list></block></block><block s="changeXPosition"><block s="reportMonadic"><l><option>neg</option></l><block s="reportProduct"><block s="reportAskFor"><block var="Point one"/><block s="reifyReporter"><autolambda><block s="reportRelationTo"><l><option>distance</option></l><block var="Point two"/></block></autolambda><list></list></block><list></list></block><l>.5</l></block></block></block><block s="doSwitchToCostume"><block s="reportPenTrailsAsCostume"></block></block><block s="doSetVar"><l>costume</l><block s="reportGet"><l><option>costume</option></l></block></block><block s="doSetVar"><l><option>my rotation x</option></l><block s="reportGet"><l><option>center x</option></l></block></block><block s="doSetVar"><l><option>my rotation y</option></l><block s="reportGet"><l><option>center y</option></l></block></block><block s="up"></block><block s="clear"></block></script></block><block s="doForever"><script><block s="doSwitchToCostume"><custom-block s="Stretchy costume | Point 1: %obj Point 2: %obj | Costume: %s"><block var="Point one"/><block var="Point two"/><block var="costume"/></custom-block></block><block s="doFaceTowards"><block var="Point two"/></block><block s="gotoXY"><custom-block s="X-Midpoint of %obj and %obj"><block var="Point one"/><block var="Point two"/></custom-block><custom-block s="Y-Midpoint of %obj and %obj"><block var="Point one"/><block var="Point two"/></custom-block></block></script></block></script></block-definition></blocks>

This worked, thank you so much! I used your block to generate a grayscale pixel array for the resized 28x28 image. I'd be happy to share that if anyone is interested, and I will be sure to credit you if the block is used in any work.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.