How to Turn a Word Into a Graphic Object?

Brahmanathaswami brahma at hindu.org
Sat Mar 28 21:28:55 EDT 2015


First: any member of the LIveCode community is always welcome... btw 
long time user Debdoot is living here for a while now Richard will 
remember him. Contact me in advance for an insider's tour of our media 
studio

@ Peter "substracted" ha! right  now it works

@ Richard:

I actually prefer this solution for this use case where WSIWIG is 
fine...  the kick of of a little word game... later I'll pull the quotes 
randomly from the server or a custom prop or a file next to the app.

on MouseUp
    put "Be All You Can Be!" into fld _quote
    wait 10 ticks
     repeat with x = 1 to the number of words of fld _Quote
        put the formattedRect of word x of fld _Quote into 
tNextWordSnapshot
             subtract 10 from item 1 of tNextWordSnapshot
             add 10 to item 3 of tNextWordSnapshot
            import snapshot from rect tNextWordSnapshot of this cd
      set the name of the last image to ("word_"&x)
      set the script of the last image to  the uWordSnapScript of this card
# the script is a mousdown handler to grab me which lets the user
# drag the image around
   end repeat
        put empty into fld _Quote
end MouseUp

Now I just have to figure out the algorithm to trigger "you got it!" 
when the user re-organizes the word/images back to their proper order.  
I think I can log the current loc of each formattedRect before taking 
the snapshot, pass that to a custom prop of each snapshot and then later 
a a kind of proximity thing that snaps them in place place if they user 
drags it close to that spot...   Maybe throw in some of Malte's 
Animation engine wizardry to make words "fly around, drop down, pile 
up... etc.) and then come to a stop

I may start a separate thread on that one... After several years of 
server side scripting this stuff is too much fun!

Swasti Astu, Be Well!
Brahmanathaswami

Kauai's Hindu Monastery
www.HimalayanAcademy.com



Richard Gaskin wrote:
> That script uses the older "from rect" option, which obtains the image 
> area from the final composite screen buffer.  It's truly WYSIWYG: if 
> it ain't visible, it ain't gonna be seen in the resulting the image.
>
> The newer "from <object>" option is much smarter and more flexible, 
> allowing you to capture any object (control, group, or even an entire 
> card) whether it's open or not.
>
> It does this by rendering the object into its own image buffer, and 
> returns the resulting image data to the newly created image object.
>
> And because it renders into its own buffer, the "from <object>" option 
> also maintains blending/transparency, so the resulting object will 
> retain empty areas as empty, in many cases making it much more useful 
> to using the resulting image as part of other layouts.
>
> Jim's script posted yesterday at 
> <http://lists.runrev.com/pipermail/use-livecode/2015-March/213144.html> creates 
> a new field object and obtains the snapshot using the newer "from 
> <object>" option, which will not only handle what you need but also 
> preserve empty space as transparent.
>
> The only modification I would suggest for Jim's script is to use 
> htmlText rather than rtfText.
>
> RtfText will handle only the subset of LiveCode text attributes that 
> are also supported by the RTF spec, which is good for most things but 
> may miss a few elements unique to LiveCode (see the note in the 
> Dictionary entry for rtfText).
>
> HtmlText is designed to provide complete fidelity of all field 
> contents and attributes in a plain-text format, making it the go-to 
> solution for moving field contents, while RtfText is ideally suited 
> for export for use in Word processors and the like.
>
>
> Extra bonus points: if you ever need to create a thumbnail view of an 
> object, see the new "at" options for specifying the width and height 
> of the resulting snapshot.  MUCH faster than the scripted solutions we 
> used to use, and very convenient.
>
>
>> If I'm write.. then perhaps we need to update the docs...(Richard/Dan...
>> is the framework for use contributions to the documentation in MarkDown
>> ready yet?)
>
> I think this entry for the Dictionary may be fine - try the "from 
> <object>" option and see how it goes.  If you do find errors there 
> please file a bug report and we'll catch them.
>
> The Community Documentation Team is growing rapidly (thanks to all 
> those who've written offering to help), and once Ben and I work out 
> some scheduling challenges we've had we'll put together a work plan to 
> get that started.
>
>
> And as long as this is in your sigline:
>> Kauai's Hindu Monastery
>> www.HimalayanAcademy.com
>
> If any of you are visiting Kauai you really should reserve time in 
> your schedule to visit the monastery.  It's a beautiful place, 
> breathtaking really, and the people who live and work there even 
> better.  When I was there they had public tours scheduled each Friday; 
> check their current schedule, and go.  You will leave with a deep 
> admiration for the uncommonly wonderful work environment 
> Brahmanathaswami gets to enjoy every day. :)




More information about the use-livecode mailing list