Skip to content

Instantly share code, notes, and snippets.

Avatar
🎨
Working on @aseprite / @igarastudio

David Capello dacap

🎨
Working on @aseprite / @igarastudio
View GitHub Profile
@dacap
dacap / cleanEdge-shadertoy.glsl
Created December 22, 2022 18:03 — forked from torcado194/cleanEdge-shadertoy.glsl
cleanEdge, a pixel art upscaling algorithm for clean rotations
View cleanEdge-shadertoy.glsl
/*** MIT LICENSE
Copyright (c) 2022 torcado
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
@dacap
dacap / New Frame Alternative.lua
Created November 28, 2022 19:07
New Frame without moving one frame tags
View New Frame Alternative.lua
local s = app.activeSprite
if not s then return end
local f = app.activeFrame
local readjustTags = {}
for _,t in ipairs(s.tags) do
if t.fromFrame.frameNumber == f.frameNumber and
t.toFrame.frameNumber == f.frameNumber then
table.insert(readjustTags, t)
@dacap
dacap / New Tilemap.lua
Created June 13, 2022 14:00
Creates a new tilemap layer with one tile per grid cell
View New Tilemap.lua
local spr = app.activeSprite
if not spr then
return app.alert "You need to create a sprite first"
end
app.transaction(
function()
app.command.NewLayer{ name="Tilemap", tilemap=true }
local grid = spr.gridBounds
for y=grid.y,spr.height,grid.width do
for x=grid.x,spr.width,grid.width do
@dacap
dacap / Trigger Tag.lua
Created April 11, 2022 00:00
Assign a key to play a tag named "TagName"
View Trigger Tag.lua
local spr = app.activeSprite
if not spr then return end
for _,t in ipairs(spr.tags) do
if t.name == "TagName" then
local old_play_once = app.preferences.editor.play_once
local old_play_all = app.preferences.editor.play_all
app.activeFrame = t.fromFrame
app.preferences.editor.play_once = true
View Enlarge Selected Cels.lua
local spr = app.activeSprite
if not spr then return end
local r = app.range
app.transaction(
function()
local oldActiveLayer = app.activeLayer
local oldActiveFrame = app.activeFrame
local deltaFrames = 0
View Enlarge All Cels.lua
local spr = app.activeSprite
if not spr then return end
app.transaction(
function()
local oldActiveLayer = app.activeLayer
local oldActiveFrame = app.activeFrame
local deltaFrames = 0
for i = #spr.frames,1,-1 do
local frame = spr.frames[i]
@dacap
dacap / Jump Tag Backward.lua
Created March 30, 2022 15:10
Aseprite scripts to jump between tags keeping the relative local frame
View Jump Tag Backward.lua
local spr = app.activeSprite
local tag = app.activeTag
local fr = app.activeFrame
if not spr or not tag then return end
local relativeFr = fr.frameNumber - tag.fromFrame.frameNumber
local function clamp(x, min, max)
if x < min then
return min
@dacap
dacap / script_filename.lua
Created January 13, 2022 11:18
Get the current Lua script filename
View script_filename.lua
function script_filename()
local source = debug.getinfo(2, "S").source
if source:sub(1, 1) == "@" then
return source:sub(2)
else
return ""
end
end
@dacap
dacap / Increment Revision And Save.lua
Created October 16, 2021 14:34
Increments the revision of the file and saves it
View Increment Revision And Save.lua
-- E.g. if the filename is called "spriteR1.png", it will rename it to "spriteR2.png" and save it.
local spr = app.activeSprite
if not spr then return app.alert "No active sprite" end
local pt = app.fs.filePathAndTitle(spr.filename)
local ext = app.fs.fileExtension(spr.filename)
-- New filename replacing the revision number at the end with its
-- incremented version
@dacap
dacap / Switch Refer to.lua
Created July 16, 2021 12:22
Script to switch the "Refer To" option for floodfill-like tools
View Switch Refer to.lua
local toolPref = app.preferences.tool(app.activeTool)
if toolPref.floodfill.refer_to == 1 then
toolPref.floodfill.refer_to = 0
else
toolPref.floodfill.refer_to = 1
end