I'm really in need for a way that a custom block could add a string as a costume - I'm currently using Mathwizz's text stamping block but it means that I have to reload the entire screen once the text has displayed due to stamping etc so what I really need is a way to display the text without stamping it :S Anyone have any idea how this could be done? Thanks!
Offline
Offline
LOL, at first I saw text as costume and I was like. 0.o Then I saw what you meant. I may look for this after my vacation... but then again it will be school time by then...
Offline
Well, maybe you should look at the code for having text in the Paint Editor.
At least 180 seconds have to pass between posts. Please wait a little while and try posting again.
Now is when I would be happy with the sixty second rule.
Offline
stamp text $String$ at x:$Number$ y:$Number$ font $String$ size $Number$ color $Color$
(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
This is all I have. You'll have to play around with it yourself because I don't have much time.
| canvas | canvas _ FormCanvas on: Form new extent: 100@100. canvas text: 'SFDgfdsGFDSgfdSGFDsgd' at: 2@2 font: (StrikeFont fontName: 'Arial' size: 30) color: Color red. costume _ ImageMedia new form: canvas form. self changed.
Mind helping me with this?
Last edited by MathWizz (2011-10-31 15:00:51)
Offline
Well looks like you have someone answering now, and I'm afraid I don't know, sorry, but Thanks for that code, I'll play around and see what I get
MESSAGE NOT UNDERSTOOD: on:extent:
replacing line 2 with
canvas := FormCanvas on: form new extent:
gives me
MESSAGE NOT UNDERSTOOD: new
Last edited by sparks (2011-10-31 15:20:12)
Offline
| canvas | canvas _ FormCanvas on: (Form new extent: 100@100). canvas text: 'SFDgfdsGFDSgfdSGFDsgd' at: 2@2 font: (StrikeFont fontName: 'Arial' size: 30) color: Color red. costume _ ImageMedia new form: canvas form. self changed.
?
Offline
This should work:
| canvas | canvas _ FormCanvas on: (Form new setExtent: 100@100 depth: 32). canvas text: 'SFDgfdsGFDSgfdSGFDsgd' at: 2@2 font: (StrikeFont fontName: 'Arial' size: 30) color: Color red. costume _ ImageMedia new form: canvas form. self changed.
Offline
Brilliant! It works really well, though the block needs to run twice for a change to appear, is there some sort of refresh-stage line needed?
EDIT: not be run twice, the project needs to be physically stopped and started with the flags, it would seem... The block also cannot be run by double-clicking it which suggests something inherently wrong somewhere...
text $String$ color $Color$ size $Number$ font $String$
| canvas | canvas _ FormCanvas on: (Form new setExtent: 100@100 depth: 32). canvas text:t1 at: 2@2 font: (StrikeFont fontName: t4 size: t3) color: t2. costume _ ImageMedia new form: canvas form. self changed.
Very cool that it technically works, though
I have plans. So many plans ^_^
Last edited by sparks (2011-11-03 19:00:48)
Offline
I don't know if this will work because I don't have Scratch on this computer:
| canvas stage | canvas _ FormCanvas on: (Form new setExtent: 100@100 depth: 32). canvas text:t1 at: 2@2 font: (StrikeFont fontName: t4 size: t3) color: t2. costume _ ImageMedia new form: canvas form. stage _ self ownerThatIsA: ScratchStageMorph. stage ifNotNil: [stage changed]. self changed.
Offline
sparks wrote:
Nope, still needs two runs to make a change
![]()
well at least we've got somewhere!
Offline
I know! This will revolutionise so much! The text-stamping is fine for most applications, but there are times when using it means refreshing the text or removing the text means re-stamping a lot of things on the screen!
Offline
text $String$ color $Color$ size $Number$ font $String$
| font csize cnv cst |
font := StrikeFont fontName: t4 size: t3.
csize := (font widthOfString: t1)@(font height).
cnv := FormCanvas on: (Form extent: csize depth: 8).
cnv text: t1 at: 0@0 font: font color: t2.
cst := ImageMedia new form: cnv form; mediaName: (self unusedMediaNameFromBaseName: costume mediaName).
media add: cst.
self lookLike: cst mediaName
Offline
nXIII wrote:
text $String$ color $Color$ size $Number$ font $String$
| font csize cnv cst |
font := StrikeFont fontName: t4 size: t3.
csize := (font widthOfString: t1)@(font height).
cnv := FormCanvas on: (Form extent: csize depth: 8).
cnv text: t1 at: 0@0 font: font color: t2.
cst := ImageMedia new form: cnv form; mediaName: (self unusedMediaNameFromBaseName: costume mediaName).
media add: cst.
self lookLike: cst mediaName
lol. It's funny how we've been trying to figure this out for ages, and now you just come online and post the code.
Offline
ProgrammingFreak wrote:
nXIII wrote:
text $String$ color $Color$ size $Number$ font $String$
| font csize cnv cst |
font := StrikeFont fontName: t4 size: t3.
csize := (font widthOfString: t1)@(font height).
cnv := FormCanvas on: (Form extent: csize depth: 8).
cnv text: t1 at: 0@0 font: font color: t2.
cst := ImageMedia new form: cnv form; mediaName: (self unusedMediaNameFromBaseName: costume mediaName).
media add: cst.
self lookLike: cst mediaNamelol. It's funny how we've been trying to figure this out for ages, and now you just come online and post the code.
![]()
well, from what I can see, his code is quite similar to mathwizz's and then again, nXIII is pretty good when it comes to smalltalk
Offline
Offline