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 / Rotate Timeline Position.lua
Created March 14, 2021 15:01
Rotate timeline position
app.preferences.general.timeline_position =
(app.preferences.general.timeline_position + 1) % 3
@dacap
dacap / Export Opaque Sprite Sheet.lua
Last active February 9, 2021 12:08
Export a sprite sheet keeping the background opaque for indexed sprites
local spr = app.activeSprite
if not spr then return print("No active sprite") end
app.command.ExportSpriteSheet()
if app.activeSprite ~= spr and
spr.backgroundLayer and
spr.colorMode == ColorMode.INDEXED then
local oldColor = app.bgColor
app.bgColor = Color(spr.transparentColor)
app.command.BackgroundFromLayer()
app.bgColor = oldColor
@dacap
dacap / Select All Frames.lua
Created January 22, 2021 21:18
Select all frames in the Aseprite timeline
local spr = app.activeSprite
if not spr then return print("No active sprite") end
local frames = {}
for i=1,#spr.frames do
frames[i] = i
end
app.range.frames = frames
@dacap
dacap / Swap Opacity.lua
Created December 16, 2020 13:05
Little Aseprite script to swap the opacity value with an alternative value specified in a floating dialog
if opacitydlg then
local toolPref = app.preferences.tool(app.activeTool)
local newValue = opacitydlg.data.opacity
opacitydlg.data = { opacity=toolPref.opacity }
toolPref.opacity = newValue
return
end
local dlg = Dialog{ title="Swap Opacity", onclose=function() opacitydlg=nil end }
dlg:slider{ id="opacity", min=0, max=255, value=app.preferences.tool(app.activeTool).opacity/2 }
@dacap
dacap / export-palette.lua
Created November 11, 2020 13:42
Export the palette of the active sprite to STDOUT as a C array
-- Usage: aseprite.exe -b my-sprite.aseprite -script export-palette.lua
--
-- Or from the UI you will see the output in a console that you can copy with Ctrl+C
--
local spr = app.activeSprite
if not spr then return print("No active sprite") end
local pal = spr.palettes[1]
print("const char palette[] = {")
@dacap
dacap / Copy-Frames-From-Files.lua
Created November 11, 2020 12:30
Aseprite script to copy multiple sprites into the active one (each sprite as a layer)
local filenames = {
"/Users/david/piano00.png",
"/Users/david/drums00.png",
"/Users/david/bass00.png"
}
local spr = app.activeSprite
if not spr then return app.alert "No active sprite" end
for _,fn in ipairs(filenames) do
@dacap
dacap / New Sprite with Preset.lua
Last active September 22, 2020 12:44
Create new sprite quickly
local s = Sprite(256, 256, ColorMode.RGB)
s:setPalette(Palette{ fromResource="DB32" })
@dacap
dacap / bash_profile.sh
Last active September 17, 2020 13:29
open/close commands // or how to never write "xdg-" or "kill -9" again
#! /bin/bash
# open file/folder/url
if [[ "$(uname)" =~ "Darwin" ]] ; then
true # do nothing because macOS already have "open" command
elif [[ "$(uname)" == "Linux" ]] ; then
alias open=xdg-open
else
alias open=start
fi
@dacap
dacap / ctrl-space.aseprite-keys
Created August 21, 2020 20:38
Ctrl+Space to zoom on Aseprite
<?xml version="1.0" encoding="utf-8" ?>
<keyboard version="1">
<commands />
<tools />
<quicktools>
<key tool="zoom" shortcut="Ctrl+Space" />
</quicktools>
<actions />
<wheel />
</keyboard>
@dacap
dacap / handy-compile.el
Created March 24, 2020 16:34
handy-compile
;; ==================================================
;; handy-compile (redefined)
;; ==================================================
(require 'bookmark)
(defun handy-current-buffer-path ()
(cond
((buffer-file-name) (file-name-directory (buffer-file-name)))
((eq major-mode 'dired-mode) (dired-current-directory))