How to Turn a Word Into a Graphic Object?

Jim Lambert jiml at netrin.com
Fri Mar 27 14:08:31 EDT 2015


> Brahma wrote:
> 
> I'm looking for a way to quickly turn words into graphic objects 
> programmatically.
> 

Text is already a kind of vector graphic.
So, this will turn words into images not graphic objects. 

> an auxiliary question: when using "import snapshot" ... how can you set 
> the name of the resulting image 

This is an elaboration of Richmond’s technique.

on word2pix startWord, endWord, theField
   if there is not a field theField then exit word2pix
   if startWord is not a number  then exit word2pix
   if endWord is not a number  then exit word2pix  
   if startWord < 1  or startWord >  the number of words of field theField then put 1 into startWord
   if endWord < 1 or endWord > the  number of words of field theField then put the  number of words of fld theField into endWord
   lock screen
   create field "dummy"
   set the margins of  field "dummy" to 0
   set the opaque of  field "dummy" to false
   set the fixedlineheight of  field "dummy" to false
   repeat with x = startWord to endWord
      set the rtftext of fld "dummy" to  the rtftext of word x of fld theField
      set the height of fld "dummy" to  the formattedheight of word 1 of fld "dummy"
      set the width of fld "dummy" to  the formattedwidth of word 1 of fld "dummy"
      import snapshot from fld "dummy"
      set the name of the last image to x &"-" & word 1 of fld "dummy"
   end repeat
   delete field "dummy"
end word2pix


Jim Lambert


More information about the use-livecode mailing list