Wallpaper Engine

Wallpaper Engine

View Stats:
Theory and maths (Help! :D)
Okay, so this gets the frames of an animation, multiplies it with a value between 0 and 1 that represents the 24 hours of the day and sets them accordingly.
So if the animation has 30 frames, frame 0 is 0, and frame 29 is 1 if I get that right.

thisLayer.getAnimation().setFrame(thisLayer.getAnimation().frameCount * engine.timeOfDay);

This here (other than it is total nonsense) literally does the same, but ONLY if it is between 12am and 12pm. Otherwise the animation is stuck at frame 0. (So with a timespan from 12am to 12pm the animation will only reach frame 14/15 until then and jump back to the start)

'use strict'; export function update(value) { if (engine.timeOfDay >= (0 / 24) && engine.timeOfDay <= (12 / 24)) { thisLayer.getAnimation().setFrame(thisLayer.getAnimation().frameCount * engine.timeOfDay); } return value; }

What I was trying to do however was, to divide the frames of said animation in between the set timespan. (To make it run from first to last frame between 12am and 12pm for this example)

How would I actually do it? (Not looking for the final code here, although I wouldn't mind it, I'm just trying to understand what to do with it and maybe, JUST maybe get something working out of it. ^^)

Can this even be done easily? How to get the timespan into the function?
Do I have to use the the WEmath stuff and const commands to specify a starting hour and an ending hour, and the do... uh SOMETHING with it?

Or should I rather forget about it because it'll fry my brain anyway? :D
< >
Showing 1-4 of 4 comments
Rhy Jan 23, 2021 @ 5:33pm 
You want to play 30 frames throughout 12 hours.

My guess would be to take the time of day, map it to 12 hours by subtracting half from it (given that 0.5 would equal 12am) and dividing it by half so we have a range from 0 to 1 over 12 hours. Then we just need to multiply it by how many frames you have.

(Timeofday-0.5)/0.5 * 30

So it would be something like .setFrame((engine.timeOfDay-0.5)/0.5*30|0)

And probably an Else or Math.max() for the first frame for if that equation is a negative value.

I haven’t testet that or have a clear mind at 2:30, but it surely is possible without any wemath functions :p
Last edited by Rhy; Jan 24, 2021 @ 3:19am
⚡Energy™⚡ Jan 24, 2021 @ 9:00pm 
Oookay, first of all thanks for the explanation. I've tried to fumble around with it for a few hours yesterday. Didn't get something useful out if it, but well, that doesn't matter, there's always the lovely script Tim dislikes so much. XD For now, that is.

Anyway, just for the theory:
Doing the whole thing for a range of 6 hours (for convenient values only and because 1/2 isn't the best example :D) would then be like this?

.setFrame((engine.timeOfDay-0.75)/0.25*30|0)
Biohazard  [developer] Jan 25, 2021 @ 5:23am 
I think this should allow you to pick whatever you like :P

So this one goes from 6 o'clock to 18 o'clock.

var numberOfHours = 12; var startHour = 6; var numFrames = thisLayer.getAnimation().frameCount; var animTime = Math.max(0, (engine.timeOfDay * (24 / numberOfHours)) - (startHour / 24)); thisLayer.getAnimation().setFrame(Math.min(numFrames - 1, numFrames * animTime));

Also haven't tested it though. But it's important to clamp the frames correctly or it will just show frame zero if the selected frame is invalid (i.e. like Pancakes said about negative values). This only matters if the time is scaled like this, otherwise it will never be invalid.
Last edited by Biohazard; Jan 25, 2021 @ 5:23am
⚡Energy™⚡ Jan 25, 2021 @ 7:01am 
Awww thank you. That wasn't really necessary but I appreciate it anyway.
I really only wanted to understand what I need to do with ll of those values and try if I can get something working out of it. :D

Well that means R.I.P. multiplier script, you were well loved, at least by me. ^^
All right, back to the testing-ground.
< >
Showing 1-4 of 4 comments
Per page: 1530 50

Date Posted: Jan 23, 2021 @ 3:46pm
Posts: 4