Skip to content

Commit 46766f7

Browse files
Revised readme and added tag exporter.
1 parent af0c72e commit 46766f7

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

Export Tags.lua

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
----------------------------------------------------------------------------------------------------
2+
-- Exports the defined tags of the sprite as individual image files according to the supplied root
3+
-- directory and the export directory specified in the user data of each tag.
4+
----------------------------------------------------------------------------------------------------
5+
6+
--
7+
-- Get a handle to the current sprite.
8+
--
9+
local spr = app.activeSprite
10+
if not spr then
11+
return app.alert("There is no active sprite.")
12+
end
13+
14+
--
15+
-- Ask the user where the root directory that they would like tags to be exported to resides.
16+
--
17+
local dlg = Dialog("Export Tags")
18+
dlg:entry{ id="directory", label="Output Directory", focus=true }
19+
dlg:slider{ id="scale", label="Scale", min=1, max=10, value=2 }
20+
:button{ id="ok", text="&Export"}
21+
:button{ text="&Cancel" }
22+
:show()
23+
24+
if not dlg.data.ok then
25+
return end
26+
27+
--
28+
-- Export each tagged frame as its own PNG file according to the exportPath defined in its user data
29+
-- and its name.
30+
--
31+
-- NOTE: Currently, we only support exporting single-frame tags and PNG files. In the future, we
32+
-- might add support for exporting multi-frame tags (either as sprite strips or as GIF files).
33+
--
34+
for i, tag in ipairs(spr.tags) do
35+
local _, exportPathKeyEnd = string.find(tag.data, "exportPath=\"")
36+
local exportPathValueEnd, _ = string.find(tag.data, "\"", (exportPathKeyEnd + 1))
37+
local exportPath = string.sub(tag.data, (exportPathKeyEnd + 1), (exportPathValueEnd - 1))
38+
local img = Image(spr.width, spr.height)
39+
40+
img:drawSprite(spr, tag.fromFrame.frameNumber, 0)
41+
img:resize(spr.width * dlg.data.scale, spr.height * dlg.data.scale)
42+
img:saveAs(dlg.data.directory .. "/" .. exportPath .. tag.name .. ".png")
43+
end
44+
45+
--
46+
-- Make sure the UI and state update.
47+
--
48+
app.refresh()

Quick Ramp (Down).lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
----------------------------------------------------------------------------------------------------
2-
-- Adjusts the hue, saturation, and lightness of the current foreground color up slightly to help
2+
-- Adjusts the hue, saturation, and lightness of the current foreground color down slightly to help
33
-- create a quick color palette ramp.
44
----------------------------------------------------------------------------------------------------
55

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Aseprite Scripts
22

3+
![Status: Complete](https://img.shields.io/badge/Work-in-Progress-blue.svg)
4+
35
Random scripts to help create art in Aseprite.

0 commit comments

Comments
 (0)