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

#1 2011-01-16 10:24:44

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

smalltalk command?

Is there a command that lets you create a costume from a specified square of the screen? e.g. "add costume from screen region x:( ) y:( ) to x:( ) y:( )"

Thanks!


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

Offline

 

#2 2011-01-16 10:26:33

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: smalltalk command?

I wanted this to, sorry I found no solution.


You can now reach me on Twitter @johnnydean1_

Offline

 

#3 2011-01-16 11:16:35

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

Re: smalltalk command?

Form fromDisplay: returns a form from the section of the display that the rectangle passed as an argument specifies.


/* No comment */

Offline

 

#4 2011-01-16 11:24:41

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

Re: smalltalk command?

so

self fromDisplay: (t1@t2)

?
EDIT: Does not work  sad

Last edited by sparks (2011-01-16 11:27:28)


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

Offline

 

#5 2011-01-16 15:46:26

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: smalltalk command?

I recommend asking your Panther Teammates. XD

I think you could do it with modification of the "grab screen region for new costume".


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#6 2011-01-16 15:53:22

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

Re: smalltalk command?

bbbeb wrote:

I recommend asking your Panther Teammates. XD

I think you could do it with modification of the "grab screen region for new costume".

Definitely. That's what I've been thinking all along while reading this thread!

Offline

 

#7 2011-01-16 15:59:17

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: smalltalk command?

LS97 wrote:

bbbeb wrote:

I recommend asking your Panther Teammates. XD

I think you could do it with modification of the "grab screen region for new costume".

Definitely. That's what I've been thinking all along while reading this thread!

Yay!
I'll go look at it, and see what I can do...


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#8 2011-01-16 16:08:31

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: smalltalk command?

This is the menu

Code:

grabSpriteFromScreen
    | t1 t2 t3 |
    (t1 _ self ownerThatIsA: ScratchFrameMorph) ifNil: [^ self].
    t2 _ ScratchSpriteMorph new.
    (t3 _ t2 grabFormFromScreen) ifNil: [^ self].
    t2 onlyCostume: t3.
    t1 addAndView: t2.

I don't think that will help.

The grabFormFromScreen is what needs to be modified, not the actual code..

EDIT:

Code:

form: t1 
    costume _ ImageMedia new form: t1.
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

That updates the costumes.
The 1st line needs to be modified, but how could we set a form to a certain part of the screen?

Last edited by bbbeb (2011-01-16 16:11:25)


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#9 2011-01-17 11:42:37

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

Re: smalltalk command?

sparks wrote:

so

self fromDisplay: (t1@t2)

?
EDIT: Does not work  sad

t1 @ t2 is a point. A rectangle is made like this: Rectangle origin:corner: The code would be:

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


/* No comment */

Offline

 

#10 2011-01-17 15:48:34

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: smalltalk command?

bbbeb wrote:

This is the menu

Code:

grabSpriteFromScreen
    | t1 t2 t3 |
    (t1 _ self ownerThatIsA: ScratchFrameMorph) ifNil: [^ self].
    t2 _ ScratchSpriteMorph new.
    (t3 _ t2 grabFormFromScreen) ifNil: [^ self].
    t2 onlyCostume: t3.
    t1 addAndView: t2.

I don't think that will help.

The grabFormFromScreen is what needs to be modified, not the actual code..

EDIT:

Code:

form: t1 
    costume _ ImageMedia new form: t1.
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

That updates the costumes.
The 1st line needs to be modified, but how could we set a form to a certain part of the screen?

TheSuccessor wrote:

sparks wrote:

so

self fromDisplay: (t1@t2)

?
EDIT: Does not work  sad

t1 @ t2 is a point. A rectangle is made like this: Rectangle origin:corner: The code would be:

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

So it would be this:

Code:

newCostume from x1: t1 y1: t2 to x2: t4 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

?


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#11 2011-01-17 15:53:56

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

Re: smalltalk command?

It's looking good, but your above block returns the following syntax error:

| t1 t2 t3 t4 |
t1 _ 10.
t2 _ 10.
t3 _ -10.
t4 _ -10.
newCostume from x1: t1 y1: t2 to x2: t4 y2: t4
    costume Nothing more expected ->_ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory


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

Offline

 

#12 2011-01-17 15:56:56

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: smalltalk command?

sparks wrote:

It's looking good, but your above block returns the following syntax error:


newCostume from x1: t1 y1: t2 to x2: t4 y2: t4

t1 _ 10.
t2 _ 10.
t3 _ -10.
t4 _ -10.
    costume_ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory.

Kill the space, and see what happens.  big_smile 
Try that code.
EDIT: And i don't think you need the top parts.
Those should be below the definition(the newCostume from:, right?)

Last edited by bbbeb (2011-01-17 15:58:28)


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#13 2011-01-17 15:58:16

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: smalltalk command?

sparks wrote:

It's looking good, but your above block returns the following syntax error:

| t1 t2 t3 t4 |
t1 _ 10.
t2 _ 10.
t3 _ -10.
t4 _ -10.
newCostume from x1: t1 y1: t2 to x2: t4 y2: t4
    costume Nothing more expected ->_ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

is costume a variable? Because it doesn't look like it's created anywhere...

Last edited by ScratchReallyROCKS (2011-01-17 15:58:30)


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#14 2011-01-17 15:59:06

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: smalltalk command?

Costume is a accessing  variable from ScriptableScratchMorph. I think.

Last edited by bbbeb (2011-01-17 15:59:21)


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#15 2011-01-17 16:02:23

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

Re: smalltalk command?

removing the space from the code like so:

Code:

newCostume from x1: t1 y1: t2 to x2: t4 y2: t4
    costume_ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

returns the same syntax error


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

Offline

 

#16 2011-01-17 16:03:55

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: smalltalk command?

sparks wrote:

removing the space from the code like so:

Code:

newCostume from x1: t1 y1: t2 to x2: t4 y2: t4
    costume_ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

returns the same syntax error

let me think.....

let me test it and see...


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#17 2011-01-17 16:06:03

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: smalltalk command?

it's the method name; it has spaces in it.

I tried this:

newCostume from x1: t1 y1: t2 to x2: t4 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

but it got me a mediaStep error.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#18 2011-01-17 16:08:19

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: smalltalk command?

I don't know, it tells me that from is a undefined variable.... any suggestions?


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#19 2011-01-17 16:09:49

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: smalltalk command?

ScratchReallyROCKS wrote:

it's the method name; it has spaces in it.

I tried this:

newCostume from x1: t1 y1: t2 to x2: t4 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

but it got me a mediaStep error.

You're right!
Try this:

newCostume x1: t1 y1: t2 to x2: t4 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#20 2011-01-17 16:12:58

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: smalltalk command?

bbbeb wrote:

ScratchReallyROCKS wrote:

it's the method name; it has spaces in it.

I tried this:

newCostume from x1: t1 y1: t2 to x2: t4 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

but it got me a mediaStep error.

You're right!
Try this:

newCostume x1: t1 y1: t2 to x2: t4 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

Sorry, I pasted the wrong thing up there. it should have been this:

newCostumeFromX1: t1 y1: t2 toX2: t3 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: t1 @ t2 corner: t3 @ t4).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

your's still had spaces in it, this doesn't. But it got me a mediaStep error.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#21 2011-01-17 16:13:04

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: smalltalk command?

bbbeb wrote:

ScratchReallyROCKS wrote:

it's the method name; it has spaces in it.

I tried this:

newCostume from x1: t1 y1: t2 to x2: t4 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

but it got me a mediaStep error.

You're right!
Try this:

newCostume x1: t1 y1: t2 to x2: t4 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

I GOT IT TO WORK WITHOUT AN ERROR (FOR NOW!!!)

Code:

getCostumeFromx1: t1 y1: t2 x2: t3 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

Testing it now...


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#22 2011-01-17 16:15:35

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: smalltalk command?

It just highlights the block like it's running, but doesn't do anything  sad

I did something that gets me an error every time I press the stop button  lol


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#23 2011-01-17 16:16:34

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: smalltalk command?

bbbeb wrote:

bbbeb wrote:

ScratchReallyROCKS wrote:

it's the method name; it has spaces in it.

I tried this:


but it got me a mediaStep error.

You're right!
Try this:

newCostume x1: t1 y1: t2 to x2: t4 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

I GOT IT TO WORK WITHOUT AN ERROR (FOR NOW!!!)

Code:

getCostumeFromx1: t1 y1: t2 x2: t3 y2: t4
    costume _ Form fromDisplay: (Rectangle origin: (t1@t2) corner: (t3@t4)).
    costume mediaName: (self unusedMediaNameFromBaseName: 'costume').
    media addLast: costume.
    self costumeChanged.
    self updateMediaCategory

Testing it now...

I'm gonna bash my head into a wall. I have to go for ~15 minutes, I'll see what i can do when i get back.


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#24 2011-01-17 16:18:48

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: smalltalk command?

I'll work on it too.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#25 2011-01-17 16:28:33

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

Re: smalltalk command?

It's looking good, it's a shame it's so difficult, it would be such a useful block!


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

Offline

 

Board footer