My proposition is to provide a simple API to allow for implementing custom inks in extensions, a mock extension code could look as follows:
function init(plugin)
plugin:newInkGroup{
id = "custom-ink-group",
title = "Custom Inks"
}
plugin:newInk{
id = "custom-ink",
title = "Custom Ink",
group = "custom-ink-group",
onclick = function(pixel, color) -- Modeled after `image:pixels()`
local pixelValue = pixel() -- get pixel
pixel(color.rgbaPixel) -- set pixel
print(pixel.x, pixel.y) -- get pixel x,y coordinates
end
}
end
function exit(plugin) end
plugin:newInkGroup
- would allow for registering a group in the ink menu so inks can be organized.
plugin:newInk
- would allow for registering a new ink in the ink menu, with parameters:
-
id
- for reference and identification -
title
- title displayed in the ink menu -
group
- if provided it would assign the ink to one of the custom ink groups, ifnil
then the ink would be assigned to an additional unnamed group to differentiate it from the core inks -
onclick
- simple function for processing pixels, modeled afterimage:pixels()
, it would provide two parameters:-
pixel
- withx
andy
coordinates of the pixel (both immutable), if called with no argument it would return the pixel value of the pixel being processed, if called with a parameter - this parameter would be treated as a new value for the pixel (accepting either Color or raw color value) -
color
- depending on user input and editor preferences it would be either the active foreground color or background color, immutable
-
And a mock extended ink menu could look like this: