Skip to content

Instantly share code, notes, and snippets.

@Sephi-Chan
Created November 3, 2018 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sephi-Chan/f3feccd5341ffe6539fd77bb995d2fd6 to your computer and use it in GitHub Desktop.
Save Sephi-Chan/f3feccd5341ffe6539fd77bb995d2fd6 to your computer and use it in GitHub Desktop.
local sprite = app.activeSprite;
local data_layer = get_layer(sprite, "Data")
local cel = data_layer.cels[1]
local image = cel.image
local red_pixel = app.pixelColor.rgba(255, 0, 0)
local origin = nil
print("sprite.width " .. sprite.width)
print("sprite.height " .. sprite.height)
print("image.width " .. image.width)
print("image.height " .. image.height)
print("Looking for " .. red_pixel)
for y = 0, sprite.height - 1 do
for x = 0, sprite.width - 1 do
pixel = image:getPixel(x, y)
print(y .. " " .. x .. " " .. pixel)
if pixel == red_pixel then
origin = { x = x, y = y }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment