This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#51 2011-01-18 15:14:49

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: smalltalk command?

oh... thats cool!!!

Offline

 

#52 2011-01-19 14:53:16

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: smalltalk command?

Code:

| screenshot |
screenshot _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).

screenshot is not yet a costume. It is a Form. Calling costume methods on it gets you an error.


/* No comment */

Offline

 

#53 2011-01-19 15:13:25

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: smalltalk command?

TheSuccessor wrote:

Code:

| screenshot |
screenshot _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).

screenshot is not yet a costume. It is a Form. Calling costume methods on it gets you an error.

Turning that into a form is a one-line action, i think. Again, I haven't been squeaking for aaages. Too busy with VB  tongue

Although, I do seem to remember it's something along the lines of
MediaItem new fromForm: [form]

note: I completely forgot what scratch's media items are called just replace that and try it

Offline

 

#54 2011-01-19 16:04:23

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: smalltalk command?

Code:

tempCostumeFromX: t1 y: t2 toX: t3 y: t4 
    costume _ ImageMedia new form: (Form fromDisplay: (Rectangle origin: t1 @ t2 corner: t3 @ t4)).
    self costumeChanged

This grabs a temporary costume from the given screen region and uses it as a costume until the costume is changed. While the sprite looks like this, you still won't see the costume in the costumes page.


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#55 2011-01-20 13:26:58

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: smalltalk command?

Hmm... bump  hmm


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#56 2011-01-21 11:39:46

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: smalltalk command?

http://t3.gstatic.com/images?q=tbn:ANd9GcQnj8qcWhZIwgMFuk4zAuIihHWArle2Sn_dAoZQA7y7dgMjnB-G2w&t=1


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#57 2011-01-22 02:34:12

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: smalltalk command?

http://www.afrifail.com/wp-content/uploads/2009/01/514_bump.jpg


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#58 2011-01-22 05:18:01

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: smalltalk command?

I am going to find a working solution NOW.


/* No comment */

Offline

 

#59 2011-01-22 05:36:27

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: smalltalk command?

Code:

grabCostumeFromX: t1 y: t2 toX: t3 y: t4
    | f f2 el topLeft bottomRight |
    topLeft _ (t1 @ (t2 negated)) + ScratchOrigin.
    bottomRight _ (t3 @ (t4 negated)) + ScratchOrigin.
    f _ Form fromDisplay: (Rectangle origin: topLeft corner: bottomRight).
    f2 _ (Form extent: (f extent + 2) depth: f depth) fillWhite.
    f displayOn: f2 at: 1@1 rule: Form over.
    f2 shapeFill: Color transparent interiorPoint: 0@0.
    f _ f2 trimBordersOfColor: Color transparent.
    el _ ImageMedia new form: f.
    el mediaName: (self unusedMediaNameFromBaseName: 'costume1').
    media addLast: el.
    self lookLike: el mediaName.

AND IT WORKS  big_smile

EDIT: But not in quarter mode  sad

Last edited by TheSuccessor (2011-01-22 05:36:57)


/* No comment */

Offline

 

#60 2011-01-22 05:39:37

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: smalltalk command?

wow.......................

Offline

 

#61 2011-01-22 06:09:35

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: smalltalk command?

Update that kind of works for quarter mode:

Code:

grabCostumeFromX: t1 y: t2 toX: t3 y: t4
    | f f2 el s q center topLeft bottomRight |
    s _ self ownerThatIsA: ScratchStageMorph.
    (q _ (self inPresentationMode not) and: [s notNil and: [s isQuarterSize]])
        ifTrue: [center _ (s left + (s width // 4)) @ (s top + (s height // 4)) * 2]
        ifFalse: [center _ ScratchOrigin].
    topLeft _ (t1 @ (t2 negated)) + center.
    bottomRight _ (t3 @ (t4 negated)) + center.
    q ifTrue: [
        topLeft _ topLeft // 2.
        bottomRight _ bottomRight // 2].
    f _ Form fromDisplay: (Rectangle origin: topLeft corner: bottomRight).
    f2 _ (Form extent: (f extent + 2) depth: f depth) fillWhite.
    f displayOn: f2 at: 1@1 rule: Form over.
    f2 shapeFill: Color transparent interiorPoint: 0@0.
    f _ f2 trimBordersOfColor: Color transparent.
    el _ ImageMedia new form: f.
    el mediaName: (self unusedMediaNameFromBaseName: 'costume1').
    media addLast: el.
    self lookLike: el mediaName.

EDIT: That doesn't work in presentation mode. Watch this space...
EDIT 2: You might be watching for a while. I just broke Scratch and am not attempting this again today.

Last edited by TheSuccessor (2011-01-22 06:26:51)


/* No comment */

Offline

 

Board footer