hi DaddiSenpai, i’ve added few lines, so now you’ll get dialog window where you can enter offset values. negative values skew the content of selection to left and/or up, positive to right and/or down:
-- skew selection
-- MAKE SELECTION FIRST
local sprt = app.activeSprite
-- default values if user doesn't enter anything
local o_x = 1 -- horizontal offset
local o_y = 1 -- vertical offset
local dlgWin = Dialog{ title = "*** SKEWER 0.1 *** " }
-- set dialog window
dlgWin
:number{ id = "x_offset",
label = "offset x"
}
:number{ id = "y_offset",
label = "offset y"
}
:button{
text = "OK",
onclick = function()
fMain(dlgWin)
end
}
-- show dialog window
dlgWin:show{ wait = false }
function fSkew(r_w, o_x, o_y)
-- don't allow values to be zero and break things
if o_x == 0 then
o_x = 1
end
if o_y == 0 then
o_y = 1
end
-- skew
for i = r_w / math.abs(o_x), 1, -1
do
-- direction right or left?
if o_x > 0 then
app.command.MoveMask{ target="boundaries", direction="right", units="pixel", quantity = o_x}
elseif o_x < 0 then
app.command.MoveMask{ target="boundaries", direction="left", units="pixel", quantity = math.abs(o_x)}
end
-- direction down or up?
if o_y > 0 then
app.command.MoveMask{ target="content", direction="down", units="pixel", quantity = o_y}
elseif o_y < 0 then
app.command.MoveMask{ target="content", direction="up", units="pixel", quantity = math.abs(o_y)}
end
end
end
function fMain(dlgWin)
local status = sprt.selection.isEmpty
local rectangle = sprt.selection.bounds
local r_w = rectangle.width
local r_h = rectangle.height
-- check if selection isn't empty
if status == false then
o_x = dlgWin.data.x_offset
o_y = dlgWin.data.y_offset
fSkew(r_w, o_x, o_y)
else
app.alert("Make selection!")
end
end
i’ve found few issues so far:
sprt.selection:deselect()
command sometimes doesn’t work - it seems like the script in some cases won’t finish properly.
however it does what it should and ctrl+z works aswell.
also wrapping app.command.MoveMask
in app.transaction( function() ... end)
to get only one undo history entry crashes aseprite almost all the time. i guess this might be a bug?
hence neither selection:deselect
nor app.transaction
are in the script now and if you get an error:
A problem has occurred.
Details:
Cannot modify the sprite.
It is being used by another command.
Try again.
click on cancel and hit escape and it will be fine.
however, just to be safe - always save your work before using this script.