Skip to content

Instantly share code, notes, and snippets.

View dacap's full-sized avatar
🎨
Programming

David Capello dacap

🎨
Programming
View GitHub Profile
@dacap
dacap / Switch Both Layers.lua
Created January 29, 2020 20:39
Switches the visibility of two layers (Back/Front) at the same time
-- Switches the visibility of the active layer, if the layer is called
-- "Something Back" or "Something Front", it will try to switch the
-- visibility of the other layer "Something Back/Front" too (so you
-- can switch the visibility of two layers at the same time).
local layer = app.activeLayer
if not layer then
return app.alert "There is no active layer"
end
@dacap
dacap / save-each-cel.lua
Created January 4, 2020 13:19
Save each cel/layer of the file in its own file
local sprite = app.activeSprite
for _,layer in ipairs(sprite.layers) do
local cel = layer.cels[1]
if cel then
cel.image:saveAs('layer-' .. cel.layer.name .. '.png')
end
end
@dacap
dacap / grafx2.lua
Created December 11, 2019 12:30
WIP grafx2 API on Aseprite
----------------------------------------------------------------------
-- grafx2 compatibility by David Capello (C) 2018-2019
----------------------------------------------------------------------
local brush = nil
local spare = nil
local function getpicture()
return app.activeImage
end
@dacap
dacap / Move Layer Down.lua
Last active April 22, 2024 19:47
Move active layer up/down in Aseprite
local layer = app.activeLayer
if layer then
layer.stackIndex = layer.stackIndex-1
end
@dacap
dacap / Export x20.lua
Created November 25, 2019 13:26
Export the active sprite to a png file scaling it to 2000%
local orig = app.activeSprite
if not orig then print("There is no active sprite to resize") end
local function replace_extension(path, newext)
local file, ext = string.match(path, "(.-)([^.]*)$")
if file and ext and file ~= "" and ext ~= "" then
return file .. newext
else
return path .. '.' .. newext
end
@dacap
dacap / clonable.cpp
Created September 25, 2019 02:33
Impl of clonable pattern https://godbolt.org/z/ZI0py6
#include <memory>
using namespace std;
// --- library ---
template<class T>
class clonable {
public:
using Base = T;
objdump -h skia_draw_text.cpp.o
skia_draw_text.cpp.o: file format Mach-O 64-bit x86-64
Sections:
Idx Name Size Address Type
0 __text 0000042b 0000000000000000 TEXT
1 __gcc_except_tab 0000009c 000000000000042c DATA
2 __literal4 00000008 00000000000004c8 DATA
3 __cstring 00000021 00000000000004d0 DATA
This file has been truncated, but you can view the full file.
libskshaper.a(libskshaper.SkShaper.o):
U __ZN17SkTextBlobBuilder15allocRunTextPosERK6SkFontii8SkStringPK6SkRect
U __ZN17SkTextBlobBuilder4makeEv
U __ZN17SkTextBlobBuilderD1Ev
00000000000006d0 T __ZN18FontMgrRunIterator7consumeEv
00000000000004e0 T __ZN18FontMgrRunIteratorC2EPKcmRK6SkFont5sk_spI9SkFontMgrE
0000000000000670 T __ZN18FontMgrRunIteratorD0Ev
0000000000000610 T __ZN18FontMgrRunIteratorD1Ev
00000000000008f0 T __ZN22StdLanguageRunIterator7consumeEv
@dacap
dacap / MoveMask Test.lua
Last active July 11, 2019 18:59
MoveMask test
local spr = app.activeSprite
spr.selection = Selection(Rectangle(0,0,spr.width,spr.height))
app.command.MoveMask{
target='content',
direction='right',
units='pixel',
quantity=2,
wrap=true
}
@dacap
dacap / Plasma.lua
Created July 4, 2019 00:17
Plasma Script for Aseprite -- https://www.aseprite.org
-- Copyright (C) 2019 David Capello
local dlg = Dialog("Plasma")
:number{ id="width", label="Size:", text="100", focus=true }
:number{ id="height", text="100" }
:number{ id="frames", label="Frames:", text="100" }
:button{ id="ok", text="OK", focus=true }
:button{ id="cancel", text="Cancel" }
dlg:show()