'set the blendlevel' executing slowly...

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

'set the blendlevel' executing slowly...

Post by paulsr » Mon Jan 06, 2014 12:57 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: 'set the blendlevel' executing slowly...

Post by Mark » Mon Jan 06, 2014 10:07 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: 'set the blendlevel' executing slowly...

Post by paulsr » Tue Jan 07, 2014 5:10 am

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: 'set the blendlevel' executing slowly...

Post by Simon » Tue Jan 07, 2014 5:35 am

Hi Paul,
On my Mac, it takes 35 seconds to execute, :shock:
Using Marks code???
try a lock/unlock messages around the repeat loop.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: 'set the blendlevel' executing slowly...

Post by paulsr » Tue Jan 07, 2014 6:59 am

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: 'set the blendlevel' executing slowly...

Post by Mark » Tue Jan 07, 2014 1:25 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: 'set the blendlevel' executing slowly...

Post by endernafi » Tue Jan 07, 2014 7:55 pm

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
Attachments
bm.png
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: 'set the blendlevel' executing slowly...

Post by endernafi » Tue Jan 07, 2014 8:01 pm

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
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: 'set the blendlevel' executing slowly...

Post by paulsr » Wed Jan 08, 2014 8:32 am

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

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: 'set the blendlevel' executing slowly...

Post by paulsr » Wed Jan 08, 2014 8:36 am

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

Post Reply