Page 1 of 2

export snapshot from colorized Text

Posted: Sat Feb 29, 2020 11:51 am
by orthomaker
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

Re: export snapshot from colorized Text

Posted: Sat Feb 29, 2020 12:05 pm
by bogs
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: )

Re: export snapshot from colorized Text

Posted: Sat Feb 29, 2020 12:29 pm
by [-hh]
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

Re: export snapshot from colorized Text

Posted: Sat Feb 29, 2020 5:13 pm
by jacque
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?

Re: export snapshot from colorized Text

Posted: Sat Feb 29, 2020 7:17 pm
by orthomaker
Thanks for answer

Re: export snapshot from colorized Text

Posted: Sat Feb 29, 2020 7:21 pm
by orthomaker
lecture1.jpg

Re: export snapshot from colorized Text

Posted: Sat Feb 29, 2020 7:23 pm
by orthomaker
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

Re: export snapshot from colorized Text

Posted: Sat Feb 29, 2020 7:24 pm
by orthomaker
lecture2.png

Re: export snapshot from colorized Text

Posted: Sat Feb 29, 2020 7:26 pm
by orthomaker
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)

Re: export snapshot from colorized Text

Posted: Sat Feb 29, 2020 7:29 pm
by orthomaker
I was running under Xubuntu 16 and Livecode 9-5

Re: export snapshot from colorized Text

Posted: Sat Feb 29, 2020 7:31 pm
by orthomaker
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

Re: export snapshot from colorized Text

Posted: Sat Feb 29, 2020 8:36 pm
by jacque
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

Re: export snapshot from colorized Text

Posted: Sun Mar 01, 2020 10:26 am
by orthomaker
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.

Re: export snapshot from colorized Text

Posted: Sun Mar 01, 2020 7:15 pm
by kaveh1000
Basic question: Is BackColor same as BackGroundColor? When I set for a field I get same result.

Re: export snapshot from colorized Text

Posted: Sun Mar 01, 2020 8:03 pm
by FourthWorld
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