Skip to content

Instantly share code, notes, and snippets.

View dacap's full-sized avatar
🎨
Programming

David Capello dacap

🎨
Programming
View GitHub Profile
math.randomseed(os.time())
chars = { ".", "O" }
for i=1,20 do
s = ""
for j=1,80 do
s = s .. chars[math.random(1, 2)]
end
print(s)
end
@dacap
dacap / Set Pixel Ratio and Center.lua
Created August 30, 2024 18:12
Shows a dialog to sets the pixel ratio of the active sprite and center the editor scroll
local dlg
dlg = Dialog("Pixel Ratio")
:entry{ id="w", label="Width", text="1" }
:entry{ id="h", label="height", text="1" }
:button{ id="test", text="Test", onclick=function()
app.sprite.pixelRatio = Size(dlg.data.w, dlg.data.h)
app.command.Zoom{ action="in" }
app.command.Zoom{ action="out" }
app.command.ScrollCenter()
end }
@dacap
dacap / Convert to Tilemap Quickly.lua
Created April 18, 2024 12:31
Convert current layer to a tilemap on Aseprite without showing the dialog
app.command.ConvertLayer{ ui=false, to="tilemap" }
@dacap
dacap / Open as RGB.lua
Created December 12, 2023 00:57
Open as RGB
local oldSprite = app.sprite
app.command.OpenFile()
if oldSprite ~= app.sprite then
app.command.ChangePixelFormat{ format="rgb" }
end
@dacap
dacap / Open with Snap to Grid.lua
Created November 21, 2023 20:24
Open with Snap to Grid
local oldSprite = app.sprite
app.command.OpenFile()
if oldSprite ~= app.sprite then
app.preferences.document(app.sprite).grid.snap = true
end
@dacap
dacap / gui.xml.diff
Created August 30, 2023 14:58
Select as the pencil
diff --git a/data/gui.xml b/data/gui.xml
index ac89a3685..2af1545bf 100644
--- a/data/gui.xml
+++ b/data/gui.xml
@@ -1315,6 +1315,13 @@
controller="one_point"
pointshape="floodfill"
tracepolicy="accumulate" />
+ <tool id="pencil_selection"
+ text="@.pencil"
----------------------------------------
Layer Head
Default Category:
Properties:
* categories table: 0x55c3cbcda3e0
* folders table: 0x55c3cbcda4f0
* id 2
----------------------------------------
Layer Tilemap 1
Default Category:
@dacap
dacap / show-category-names.lua
Created July 3, 2023 23:50
Usage: aseprite -b file.aseprite -script show-category-names.lua
local PK = "aseprite/Attachment-System"
local sprite = app.activeSprite
function find_tileset_by_catID(catID)
for _,ts in ipairs(sprite.tilesets) do
if ts.properties(PK) and
ts.properties(PK).id == catID then
return ts
end
end
@dacap
dacap / Switch Non-Active Layer Opacity.lua
Created July 3, 2023 22:50
Switch Non-Active Layer Opacity
if app.preferences.experimental.nonactive_layers_opacity == 255 then
app.preferences.experimental.nonactive_layers_opacity = 128
else
app.preferences.experimental.nonactive_layers_opacity = 255
end
@dacap
dacap / cara-o-cruz.lua
Created May 26, 2023 23:54
Cara o cruz
if math.random(1, 2) == 1 then
print "Cara"
else
print "Cruz"
end