How to Turn a Word Into a Graphic Object?

Brahmanathaswami brahma at hindu.org
Sat Mar 28 01:00:04 EDT 2015


Thanks Scott:

With formattedRect this turned out to be "ridiculously" simple:

on MouseUp
     repeat with x = 1 to the number of words of fld _Quote
           put the formattedRect of word x of fld _Quote into 
tNextWordSnapshot

      # add space left and right
       --substract 4 from item 1 of tNextWordSnapshot  # won't even compile!
       --add 4 to item 3 of tNextWordSnapshot

          import snapshot from rect tNextWordSnapshot of this cd
          set the name of the last image to ("word_"&x)
   end repeat
end MouseUp


BUT FYI in LC8 the simple math on items in a rect list is not working... 
script will not even compile.. .even though docs use this exact same 
example:

put"10,10"intotPoint subtract5fromitem2oftPoint -- subtracts 5 from the 
second item

Am I doing something wrong?... can anyone confirm?

Also:  I don't see how this (in the docs on snapshot) can apply for 
snapshots of words in a field as these are not "objects" perse:

" You can take a snapshot of an object regardless of its visibility or 
open status - in particular, snapshots can be taken of objects that are 
not on the current card or in stacks that are not open.

an attempt like this results in "empty rectangle"

on MouseUp
    repeat with x = 1 to the number of words of fld _Quote of cd 2
       put the formattedRect of word x of fld _Quote of cd 2 into 
tNextWordSnapshot
       import snapshot from rect tNextWordSnapshot of cd 2
      set the name of the last image to ("word_"&x)
   end repeat
end MouseUp

Also if you turn the vis of the field off... you get snaps shots of 
whatever is visible on the card, not the words in the field...

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?)

Swasti Astu, Be Well!
Brahmanathaswami

Kauai's Hindu Monastery
www.HimalayanAcademy.com



Scott Rossi wrote:
> See the formattedRect property and measureText function in the docs.  Both
> should help you get what you want.
>
> ³Last² refers to the object type that is highest in the hierarchy:
> set the name of the last image to ³myImage"
>
> Also, the number of an object type will return the number of the highest
> layered object:
> put the number of images into N
> set the name of image N to ³myImage"
>
> Regards,
>
> Scott Rossi
> Creative Director
> Tactile Media, UX/UI Design



More information about the Use-livecode mailing list