local dlg = Dialog()
width = 200,
height = 200,
onpaint = function(ev)
local gc = ev.context
gc.opacity = 255
gc.blendMode = BlendMode.NORMAL
local preview = app.sprite
-- Create a rectangle and use it as a clipping region
gc:rect(Rectangle(10, 10, 100, 40))
gc: drawImage(preview, 20,20)
Hello, I want to create a preview function.
what I want to do is draw ‘app.sprite’ used GraphicsContext.
I don’t know why this program can’t draw the sprite.
please tell me.
edit: image exists at [ layer1 frame1]
i assume it doesn’t work because the image in question is not an image, but an active sprite. sprite contains layers and frames and those two point to cels and the cels are the ones containing image. you can access all of these, but sometimes it can get a bit confusing.
so, depending on what you need you have to get the source image from elsewhere.
i might be very wrong, but personally i would first try
local preview = Image(app.sprite) to see if it works. if not - or you need more/other functionality (this should get you just an image from 1st frame in sprite) - check api documentation: https://github.com/aseprite/api/blob/main/api/image.md#image-1