oh... thats cool!!!
Offline
| 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.
Offline
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
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
tempCostumeFromX: t1 y: t2 toX: t3 y: t4
costume _ ImageMedia new form: (Form fromDisplay: (Rectangle origin: t1 @ t2 corner: t3 @ t4)).
self costumeChangedThis 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.
Offline
I am going to find a working solution NOW.
Offline
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
EDIT: But not in quarter mode
Last edited by TheSuccessor (2011-01-22 05:36:57)
Offline
wow.......................
Offline
Update that kind of works for quarter mode:
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)
Offline