How to make a smooth stop of the background?

Hello. How to make a smooth stop of the background? The program has a change in frame rate, but it starts to act instantly. I need every next frame to be slower
of the past. Is it possible to do this automatically?

Generally, a Lua script is handy to automate Aseprite tasks. Not sure I understand exactly what you’re after, but imagine I’ve got a sprite with 20 frames. I want frames 11 to 20 to go from 20 milliseconds to 200 milliseconds in duration. A script like this would do that:

local startFrIdx <const> = 11
local startMillis <const> = 20

local stopFrIdx <const> = 20
local stopMillis <const> = 200

local activeSprite <const> = app.sprite
if not activeSprite then return end
local frObjs <const> = activeSprite.frames
local lenFrObjs <const> = #frObjs

local startSec = math.min(math.max(startMillis * 0.001, 0.001), 65.535)
local stopSec = math.min(math.max(stopMillis * 0.001, 0.001), 65.535)

local startFrIdxVerif = math.min(math.max(startFrIdx, 1), lenFrObjs)
local stopFrIdxVerif = math.min(math.max(stopFrIdx, 1), lenFrObjs)
if stopFrIdxVerif < startFrIdxVerif then
    startFrIdxVerif, stopFrIdxVerif = stopFrIdxVerif, startFrIdxVerif
    startSec, stopSec = stopSec, startSec

local count <const> = 1 + stopFrIdxVerif - startFrIdxVerif
local i = 0
while i < count do
    local t <const> = i / (count - 1.0)
    local u <const> = 1.0 - t
    local currSec <const> = u * startSec + t * stopSec
    local frObj <const> = frObjs[startFrIdxVerif + i]
    frObj.duration = currSec
    i = i + 1

Although the UI shows duration in milliseconds (an integer), the Frame’s duration is stored in seconds (a real number), so divided by 1000.0.

Edit: I should add that frame duration impacts every layer. Separate layers do not have an independent duration. So if this wouldn’t help if you wanted to to isolate just the background layer’s duration.

Hi. Thanks for your help. I’ll try it later

I’m not good at lua. What needs to be done to make this code work?

Hello. I figured out this code and that’s what I need. Thank you very much.

1 Like