Set animation speed on export

When exporting an animation via the Export... dialog, it would be nice to be able to set a speed multiplier that gets applied to every frame duration. This could be a drop-down like in the preview window, or a text field where you enter your own multiplier, or both, with a drop-down that has a “Custom” option.

For me, this would be useful for exporting unfinished animations consisting only of key frames so that they have the same length as the final animation would, without having to manually edit the frame durations, which is error-prone. It could also be useful for experimenting with different animation lengths in game engines that don’t let you scale the animation speed.

2 Likes

i bodged this little script:

-- MULTIPLY FRAME DURATION v0.01 

-- this script will: 
-- ask you for multiplier (slider) 
-- duplicate current sprite (with dialog) 
-- multiply duration of each frame 
-- export file (with export dialog) 


local mult = 0.00000 
local dlgWin = Dialog{ title = "EXPORT MULTIPLY" } 


dlgWin
	:slider{ 
		id = "mult_val", 
		min = 1, 
		max = 10, 
		value = 2 
	}
	
	:button{ 
		text = "MAGIC!", 
		onclick = function()
			fMain(dlgWin) 
		end 
	} 
	
dlgWin:show{ wait = false } 


function fMain(dlgWin) 

	app.command.DuplicateSprite() 
	
	local sprite = app.activeSprite 
	local mult = dlgWin.data.mult_val 
	
	for i,frame in ipairs(sprite.frames) do
		local duration = frame.duration 
		frame.duration = duration * mult
	end
	
	app.command.SaveFileCopyAs() 
	dlgWin:close() 
end 

here’s a text field version:

-- MULTIPLY FRAME DURATION v0.02

-- this script will: 
-- ask you for multiplier (text field) 
-- duplicate current sprite (with dialog) 
-- multiply duration of each frame 
-- export file (with export dialog) 


local mult = 0.00000 
local dlgWin = Dialog{ title = "EXPORT MULTIPLY" } 


dlgWin
	:entry{ id = "mult_val",
           focus = true } 
	
	:button{ 
		text = "MAGIC!", 
		onclick = function()
			fMain(dlgWin) 
		end 
	} 
	
dlgWin:show{ wait = false } 


function fMain(dlgWin) 

	app.command.DuplicateSprite() 
	
	local sprite = app.activeSprite 
	local mult = tonumber( dlgWin.data.mult_val ) 
	
	for i,frame in ipairs(sprite.frames) do
		local duration = frame.duration 
		frame.duration = duration * mult
	end
	
	app.command.SaveFileCopyAs() 
	dlgWin:close() 
end 

note: don’t hit enter after entering a multiplier number - it will just start preview…

1 Like

Neat, thank you!