How to Turn a Word Into a Graphic Object?

Mark Schonewille m.schonewille at economy-x-talk.com
Fri Mar 27 02:53:11 EDT 2015


Hi Brahmanathaswami,

Here's an example.

// button script
on mouseUp
      put the selectedRect of fld 1 into myRect
      if myRect is not "error" then
           import snapshot from rect myRect of this cd
           put the long id of it into myImage
           // do something with myImage here
      end if
end mouseUp

// card or stack script
getProp selectedRect theChunk
      try
           if theChunk is empty then
                put the selectedChunk of the target into myChunk
           else
                put theChunk into myChunk
           end if
           put the formattedWidth of the selectedChunk into myWidth
           put word 2 of myChunk & comma & word 4 of myChunk into myChars
           sort items of myChars numeric
           select char (item 1 of myChars) of the target
           put the selectedLoc into myRect
           select char (item 2 of myChars) of the target
           put comma & the selectedLoc after myRect
           add the formattedHeight of the selectedChunk to item 4 of myRect
           put item 1 of myRect + myWidth into item 3 of myRect
           select empty
           return myRect
      catch myErr
           return "error"
      end try
end selectedRect

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Installer Maker for LiveCode:
http://qery.us/468

Buy my new book "Programming LiveCode for the Real Beginner" 
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 3/27/2015 07:28, Brahmanathaswami wrote:
> I'm looking for a way to quickly turn words into graphic objects
> programmatically.
>
> If you have a field with the words
>
> "I am that I am"
>
> you can programmatically select each word and highlight it etc. but I
> don't think you can get the actual pixel location of the rect that the
> hilite takes on the screen... which, theoretically should be doable,
> since everything must be drawn on screen, everything has x,y coords and
> width and height.
>
> Assuming the rect of a hilited word *could* be extracted, then it would
> be easy to take a import a snap shot of it.
>
> an auxiliary question: when using "import snapshot" ... how can you set
> the name of the resulting image that is placed on the top of the card.
> It defaults to (e.g.) "image id 6578"  but one cannot know that ID... is
> there another way to refer to the latest created object?
>
> Swasti Astu, Be Well!
> Brahmanathaswami
>
>




More information about the use-livecode mailing list