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

#1 2011-06-22 21:50:25

waveOSBeta
Scratcher
Registered: 2009-12-08
Posts: 1000+

[draw text [] at x() y()] block

Anybody have teh code?


http://internetometer.com/image/10202.png]
New signature coming soon!  smile

Offline

 

#2 2011-06-22 22:07:08

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: [draw text [] at x() y()] block

waveOSBeta wrote:

Anybody have teh code?

I hope this comes out in Scratch 2.0...  big_smile


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#3 2011-06-23 04:32:52

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

Re: [draw text [] at x() y()] block

stamp text $String$ at x:$Number$ y:$Number$ font $String$ size $Number$ color $Color$

Code:

(stage := self ownerThatIsA: ScratchStageMorph) ifNotNil: [stage createOrResizeTrailsForm. form := stage penTrailsForm] ifNil: [^ self].
canvas := FormCanvas on: form.
canvas text: t1 at: t2+240@(t3 negated + 180) font: (StrikeFont fontName: t4 size: t5) color: t6.
stage changed.

All credit to MathWizz, he made this and I use it all the time! One of the most useful blocks Scratch never made!

A few notes: if you don't enter a standard font size it wont make it that size, it will jump to around size 10 and if you leave the font space blank then a default font is used which I find the safest option as if the font you enter isn't on the viewers computer it can cause layout problems.

enjoy  smile


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

Offline

 

#4 2011-06-23 04:37:02

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

Re: [draw text [] at x() y()] block

This is actually already online in the Panther > Pen section of the block library along with rectangle and oval drawing blocks to compliment it!


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

Offline

 

#5 2011-06-23 05:05:10

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: [draw text [] at x() y()] block

sparks wrote:

This is actually already online in the Panther > Pen section of the block library along with rectangle and oval drawing blocks to compliment it!

Oh, great! I was wondering where it is; I saw it in your block lib stats project.  smile

Offline

 

#6 2011-06-23 05:44:59

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

Re: [draw text [] at x() y()] block

Yes, I used the text stamping and the rectangle drawing blocks to get my stats project to display quickly  smile  Very useful indeed. Using the rectangle drawing tool you can do some pretty nice things!


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

Offline

 

#7 2011-06-23 06:35:53

waveOSBeta
Scratcher
Registered: 2009-12-08
Posts: 1000+

Re: [draw text [] at x() y()] block

sparks wrote:

stamp text $String$ at x:$Number$ y:$Number$ font $String$ size $Number$ color $Color$

Code:

(stage := self ownerThatIsA: ScratchStageMorph) ifNotNil: [stage createOrResizeTrailsForm. form := stage penTrailsForm] ifNil: [^ self].
canvas := FormCanvas on: form.
canvas text: t1 at: t2+240@(t3 negated + 180) font: (StrikeFont fontName: t4 size: t5) color: t6.
stage changed.

All credit to MathWizz, he made this and I use it all the time! One of the most useful blocks Scratch never made!

A few notes: if you don't enter a standard font size it wont make it that size, it will jump to around size 10 and if you leave the font space blank then a default font is used which I find the safest option as if the font you enter isn't on the viewers computer it can cause layout problems.

enjoy  smile

Wow, thanks! Is it possible to use this in scratch by changing the $something$ things?


http://internetometer.com/image/10202.png]
New signature coming soon!  smile

Offline

 

#8 2011-06-23 07:44:00

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: [draw text [] at x() y()] block

waveOSBeta wrote:

sparks wrote:

stamp text $String$ at x:$Number$ y:$Number$ font $String$ size $Number$ color $Color$

Code:

(stage := self ownerThatIsA: ScratchStageMorph) ifNotNil: [stage createOrResizeTrailsForm. form := stage penTrailsForm] ifNil: [^ self].
canvas := FormCanvas on: form.
canvas text: t1 at: t2+240@(t3 negated + 180) font: (StrikeFont fontName: t4 size: t5) color: t6.
stage changed.

All credit to MathWizz, he made this and I use it all the time! One of the most useful blocks Scratch never made!

A few notes: if you don't enter a standard font size it wont make it that size, it will jump to around size 10 and if you leave the font space blank then a default font is used which I find the safest option as if the font you enter isn't on the viewers computer it can cause layout problems.

enjoy  smile

Wow, thanks! Is it possible to use this in scratch by changing the $something$ things?

('stamp text %s at x:%n y:%n' #- #stampText:atX:y: 'text' 0 0)

stampText: t1 atX: t2 y: t3
(stage := self ownerThatIsA: ScratchStageMorph) ifNotNil: [stage createOrResizeTrailsForm. form := stage penTrailsForm] ifNil: [^ self].
canvas := FormCanvas on: form.
canvas text: t1 at: t2+240@(t3 negated + 180) font: (StrikeFont fontName: t4 size: t5) color: t6.
stage changed.

Offline

 

#9 2011-06-23 11:02:06

waveOSBeta
Scratcher
Registered: 2009-12-08
Posts: 1000+

Re: [draw text [] at x() y()] block

Stage is an unknown variable...  sad


http://internetometer.com/image/10202.png]
New signature coming soon!  smile

Offline

 

#10 2011-06-23 13:40:36

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

Re: [draw text [] at x() y()] block

odd... it really should work in Scratch but I've only used it in Panther. Perhaps it can't find stage in the area of the browser you placed it? Contact MathWizz, he might know!


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

Offline

 

#11 2011-06-23 13:54:53

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: [draw text [] at x() y()] block

waveOSBeta wrote:

Stage is an unknown variable...  sad

add it to the variables of that method, it will work I think... IDK why... that's what I did.

Last edited by Pecola1 (2011-06-23 13:55:20)


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#12 2011-06-23 13:55:12

waveOSBeta
Scratcher
Registered: 2009-12-08
Posts: 1000+

Re: [draw text [] at x() y()] block

Tried all 3... MathWizz?


http://internetometer.com/image/10202.png]
New signature coming soon!  smile

Offline

 

#13 2011-06-23 16:05:17

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: [draw text [] at x() y()] block

Mmmm...
*opens Scratch*

EDIT:
Try this:

Code:

('stamp text %s with font %s' #- #stampText:font: 'Hello, World' 'Arail')

Code:

stampText: text font: font 
    | stage form canvas |
    (stage _ self ownerThatIsA: ScratchStageMorph) ifNil: [^ self].
    stage createOrResizeTrailsForm.
    form _ stage penTrailsForm.
    canvas _ FormCanvas on: form.
    canvas
        text: text
        at: self xpos + 240 @ (self ypos negated + 180)
        font: (StrikeFont fontName: font size: penSize)
        color: penColor.
    stage changed

Last edited by MathWizz (2011-06-23 16:22:33)


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#14 2011-06-23 16:55:19

waveOSBeta
Scratcher
Registered: 2009-12-08
Posts: 1000+

Re: [draw text [] at x() y()] block

MathWizz wrote:

Mmmm...
*opens Scratch*

EDIT:
Try this:

Code:

('stamp text %s with font %s' #- #stampText:font: 'Hello, World' 'Arail')

Code:

stampText: text font: font 
    | stage form canvas |
    (stage _ self ownerThatIsA: ScratchStageMorph) ifNil: [^ self].
    stage createOrResizeTrailsForm.
    form _ stage penTrailsForm.
    canvas _ FormCanvas on: form.
    canvas
        text: text
        at: self xpos + 240 @ (self ypos negated + 180)
        font: (StrikeFont fontName: font size: penSize)
        color: penColor.
    stage changed

penSize ain't a variable, all that jazz. Any other ideas?


http://internetometer.com/image/10202.png]
New signature coming soon!  smile

Offline

 

#15 2011-06-23 17:49:20

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: [draw text [] at x() y()] block

It goes into the ScratchSpriteMorph.


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#16 2011-06-23 17:54:04

waveOSBeta
Scratcher
Registered: 2009-12-08
Posts: 1000+

Re: [draw text [] at x() y()] block

The block stays highlighted, it doesn't work.


http://internetometer.com/image/10202.png]
New signature coming soon!  smile

Offline

 

#17 2011-06-23 21:58:01

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: [draw text [] at x() y()] block

If it stays highlighted, click the stop button and run it again.


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#18 2011-06-24 13:04:58

waveOSBeta
Scratcher
Registered: 2009-12-08
Posts: 1000+

Re: [draw text [] at x() y()] block

MathWizz wrote:

If it stays highlighted, click the stop button and run it again.

Nope.  sad


http://internetometer.com/image/10202.png]
New signature coming soon!  smile

Offline

 

#19 2011-06-25 12:06:08

waveOSBeta
Scratcher
Registered: 2009-12-08
Posts: 1000+

Re: [draw text [] at x() y()] block

Bumpmubmpub Mphinhihiknknikjjdsihisk

^^'


http://internetometer.com/image/10202.png]
New signature coming soon!  smile

Offline

 

#20 2011-06-25 13:30:08

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

Re: [draw text [] at x() y()] block

I was going to do this in a mod a was going to make a year ago. 0_e

Offline

 

#21 2011-06-26 12:19:31

waveOSBeta
Scratcher
Registered: 2009-12-08
Posts: 1000+

Re: [draw text [] at x() y()] block

waveOSBeta wrote:

Bumpmubmpub Mphinhihiknknikjjdsihisk

^^'


http://internetometer.com/image/10202.png]
New signature coming soon!  smile

Offline

 

Board footer