Page 1 of 1
'set the blendlevel' executing slowly...
Posted: Mon Jan 06, 2014 12:57 pm
by paulsr
Greetings:
I'm trying to get a dissolve effect for some items on a card. I've tried various things, and this is just a simple example of what I need. GrpP1 contains a couple of text areas and a couple of small images. GrpGAL has one larger image and one line of text. I'd just like to have a smooth transition between the two.
Code: Select all
set the blendlevel of grp "GrpP1" to 33
set the blendlevel of grp "GrpGAL" to 66
set the blendlevel of grp "GrpP1" to 66
set the blendlevel of grp "GrpGAL" to 33
set the blendlevel of grp "GrpP1" to 100
set the blendlevel of grp "GrpGAL" to 0
If I run this on my Mac, I don't see any effect other than one group disappearing and the other appearing. This is what I'd expect.
But if I run this on an iPad (retina or non) the effect takes about
eight seconds!
Can someone plz explain to me why this is taking so long, and hopefully tell me how to achieve a smooth blend in about one second.
I'm using LC 6.5.1
Many tkx...
--paul
Re: 'set the blendlevel' executing slowly...
Posted: Mon Jan 06, 2014 10:07 pm
by Mark
Hi Paul,
Try this:
Code: Select all
repeat with x = 1 to 100 with messages
set the blendLevel of grp "grpP1" to x
set the blendLevel of grp "grpGAL" to (100-x)
wait 10 milliseconds with messages
end repeat
This script changes the blendLevel from 100 to 0 resp. 0 to 100 in 1 second.
Kind regards,
Mark
Re: 'set the blendlevel' executing slowly...
Posted: Tue Jan 07, 2014 5:10 am
by paulsr
Thanks Marc,
That's pretty-much the code I started with. On my Mac, it takes 35 seconds to execute, and on an iPad ... 4 minutes!!!
That's why I stripped it down to a few statements, to see what was happening. Why would six lines of code, with no waits, take eight seconds?
Clearly I've done something stupid somewhere.
BTW: I do have 'set the acceleratedRendering of me to true' in preOpenStack. I'm not sure what this does, but it seems to be aGoodThing!
Any ideas? Thanks...
--paul
Re: 'set the blendlevel' executing slowly...
Posted: Tue Jan 07, 2014 5:35 am
by Simon
Hi Paul,
On my Mac, it takes 35 seconds to execute,
Using Marks code???
try a lock/unlock messages around the repeat loop.
Simon
Re: 'set the blendlevel' executing slowly...
Posted: Tue Jan 07, 2014 6:59 am
by paulsr
Yes Simon, using Mark's code.
Thanks, but 'lock messages' made no difference.
I have to think I'm barking up the wrong tree, but I can't figure how to find the right tree!
--paul
Re: 'set the blendlevel' executing slowly...
Posted: Tue Jan 07, 2014 1:25 pm
by Mark
Hi Paul,
Could you quit LiveCode, start it again, preferably without plugins, make a new stack with just a few buttons to create two groups, and try my script again? If it doesn't finish running in one second, something strange is going on.
Do you have any other scripts running in your original stack, while you run the repeat loop I posted?
Locking messages won't help in any way and you should make sure that the lockMessages has been set to false. No other script should have set the lockMessages to true while running this script. Also, you need to make sure that the lockScreen is false.
AcceleratedRendering should make things go faster and this option should work quite nicely on iPads, but obviously you can try without to see what happens.
Kind regards,
Mark
Re: 'set the blendlevel' executing slowly...
Posted: Tue Jan 07, 2014 7:55 pm
by endernafi
In this case, turning on the acceleratedRendering seems to make things worse.
I've attached the results of a quick test.
1 card, 2 default buttons the effects to be applied, 1 button with the Mark's script.
Setting the buttons' layerModes to "dynamic" or "static" didn't change the benchmark results.
Paul's results are way too high, of course.
Probably another code is interfering and slowing things down, as Mark stated.
Of course, increasing the step will always help; the effect will be smooth enough:
Code: Select all
repeat with x=0 to 100 step 2
end repeat
Best,
~ Ender Nafi
Re: 'set the blendlevel' executing slowly...
Posted: Tue Jan 07, 2014 8:01 pm
by endernafi
Paul,
I've just re-read your post and this caught my attention:
paulsr wrote:I'd just like to have a smooth transition between the two.
You may want to use a built-in effect for this, give it a try if it suits for your needs:
Code: Select all
lock screen for visual effect
hide grp "GrpP1"
show grp "GrpGAL"
unlock screen with visual effect "dissolve fast"
You can even narrow the effect down to a specific region
by appending
in rect (the rect of grp "GrpP1") to the first line.
Best,
~ Ender Nafi
Re: 'set the blendlevel' executing slowly...
Posted: Wed Jan 08, 2014 8:32 am
by paulsr
Mark wrote:Hi Paul,
Could you quit LiveCode, start it again, preferably without plugins, make a new stack with just a few buttons to create two groups, and try my script again? If it doesn't finish running in one second, something strange is going on.
Do you have any other scripts running in your original stack, while you run the repeat loop I posted?
Locking messages won't help in any way and you should make sure that the lockMessages has been set to false. No other script should have set the lockMessages to true while running this script. Also, you need to make sure that the lockScreen is false.
AcceleratedRendering should make things go faster and this option should work quite nicely on iPads, but obviously you can try without to see what happens.
Kind regards,
Mark
Okay Mark, I did as you suggested... created a new stack with just a couple of text fields and a button. Tapping the button causes one text field to fade out and the other to fade in. It works just fine on my iPad retina.
I've tried commenting out anything in my original script which I thought could be causing the problem, but nothing makes any difference. AcceleratedRendering doesn't seem to do much whether set or not.
I could keep plugging away at this, but please see my next message...
--paul
Re: 'set the blendlevel' executing slowly...
Posted: Wed Jan 08, 2014 8:36 am
by paulsr
Many thanks guys for the helpful suggestions.
Ender Nafi's idea to use:
Code: Select all
lock screen for visual effect
hide grp "GrpP1"
show grp "GrpGAL"
unlock screen with visual effect "dissolve fast"
...works just fine. Great idea!
For now, I'll work with this solution, while making a mental note not to fiddle with blendlevels.
If I ever figure out what was causing the problem, I'll let y'all know.
Thanks again...
--paul