export snapshot from colorized Text

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

orthomaker
Posts: 14
Joined: Sat Feb 29, 2020 11:23 am

export snapshot from colorized Text

Post by orthomaker » Sat Feb 29, 2020 11:51 am

Hello,

I have made a program . I use backColor of text field to help child reading.
I want to take a snapshot of the text as PNG.
It's OK for one picture when I do this manually. One button to colorize and after one button to take snapshot.

But when I want to do it for multiple pages, I do this script below.

Code: Select all

  
  colorText tID
      wait until the effective backColor of word -1 of field "texte" is "mixed"

      
      put fPath&"/"&eName&"part"&P&".png" into long_fName
      export snapshot from rect  newRect to file longfName as PNG
      
      
the exported pictures were partially colorized, I suppose because the "wait until" command doesn't work correctly.
Does anyone know how to solve this problem?

Thanks

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: export snapshot from colorized Text

Post by bogs » Sat Feb 29, 2020 12:05 pm

I suspect there must be a lot more to the relevant code than what you have listed, but that aside for the moment, which OS and LiveCode version are you using?

Why are you setting the backColor of words separately, apparently, instead of just setting the backColor of the entire field, which is what it looks like you want? Or are you trying to get sequential shots every time the last word is backColored?

What are you using to determine the rect of newRect (since you imply the snapshot is taken, this is the least important question I have, more of a curiosity if you will :wink: )
Image

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: export snapshot from colorized Text

Post by [-hh] » Sat Feb 29, 2020 12:29 pm

Instead of "wait" use "send in time":

Code: Select all

on mouseUp
  -- change text colors here and set variable tID
  send "colorText tID" to me in 0.5 seconds
end mouseUp

on colorText tID
  put fPath&"/"&eName&"part"&P&".png" into long_fName
  export snapshot from rect  newRect to file longfName as PNG
end colorText
shiftLock happens

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: export snapshot from colorized Text

Post by jacque » Sat Feb 29, 2020 5:13 pm

I'm not sure you need the wait at all. That line won't run until the previous one has completed, and by then the colorizing should be done. Is there a reason to include a wait time?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

orthomaker
Posts: 14
Joined: Sat Feb 29, 2020 11:23 am

Re: export snapshot from colorized Text

Post by orthomaker » Sat Feb 29, 2020 7:17 pm

Thanks for answer

orthomaker
Posts: 14
Joined: Sat Feb 29, 2020 11:23 am

Re: export snapshot from colorized Text

Post by orthomaker » Sat Feb 29, 2020 7:21 pm

lecture1.jpg

orthomaker
Posts: 14
Joined: Sat Feb 29, 2020 11:23 am

Re: export snapshot from colorized Text

Post by orthomaker » Sat Feb 29, 2020 7:23 pm

The COLORTEXT fonction colorize text according to the french syllabe parsing with many colors and addtionnal sign
tID is the long name of the target Field

orthomaker
Posts: 14
Joined: Sat Feb 29, 2020 11:23 am

Re: export snapshot from colorized Text

Post by orthomaker » Sat Feb 29, 2020 7:24 pm

lecture2.png

orthomaker
Posts: 14
Joined: Sat Feb 29, 2020 11:23 am

Re: export snapshot from colorized Text

Post by orthomaker » Sat Feb 29, 2020 7:26 pm

but when I export snapshot , I got only the first word in color ...

colorizing text take a long time under Galaxy Tab E ( 15 second per page ) and I 'm looking for a way to to this without using an arbitrary "send in time".
the program may have to colorize and export succesively a lot of page ( a complete book)

orthomaker
Posts: 14
Joined: Sat Feb 29, 2020 11:23 am

Re: export snapshot from colorized Text

Post by orthomaker » Sat Feb 29, 2020 7:29 pm

I was running under Xubuntu 16 and Livecode 9-5

orthomaker
Posts: 14
Joined: Sat Feb 29, 2020 11:23 am

Re: export snapshot from colorized Text

Post by orthomaker » Sat Feb 29, 2020 7:31 pm

The target of deployment was a lot of Samsung galaxy Tab E from my school under Android 4.4

PS : Sorry for multiple post , forum server reject

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: export snapshot from colorized Text

Post by jacque » Sat Feb 29, 2020 8:36 pm

Thanks for the image, that helps a lot. If you are setting the colors by changing the field text it will take a long time. It will be faster to work with the htmltext in a variable, but even faster to work with style runs in a text array. I recently found out how fast style runs are, and it makes a big difference.

If you get the styledText property of the field, you can go through the array and set the color for each style run. This is a little more complicated than just setting the backcolor of text in a field but it is very fast. If you are comfortable with arrays, this may be something you want to look at.

For the image, it sounds like you want the entire field. You can use:

Code: Select all

export snapshot from field "myField' to file longfName as PNG
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

orthomaker
Posts: 14
Joined: Sat Feb 29, 2020 11:23 am

Re: export snapshot from colorized Text

Post by orthomaker » Sun Mar 01, 2020 10:26 am

Hello,
I have found the problem.
It was not a "wait" problem but a "lock screen" problem.
I have more "lock screen" than I need.

This code was write 10 years ago with Revolution 2.7.

Export work well now.

Thanks for your help again.

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: export snapshot from colorized Text

Post by kaveh1000 » Sun Mar 01, 2020 7:15 pm

Basic question: Is BackColor same as BackGroundColor? When I set for a field I get same result.
Kaveh

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: export snapshot from colorized Text

Post by FourthWorld » Sun Mar 01, 2020 8:03 pm

kaveh1000 wrote:
Sun Mar 01, 2020 7:15 pm
Basic question: Is BackColor same as BackGroundColor? When I set for a field I get same result.
See the "Synonyms" section of the Dictionary entry for a language token to see what synonyms are provided:
https://livecode.com/resources/api/#liv ... roundcolor
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Multimedia”