Skip to content

Draft: Lua image lib

Lactozilla requested to merge lua-gfx-2 into next

Merge !2104 (merged) first.

Documentation:

Adds: image.create, image.patchExists (might rename), image.getPatch (might rename), image.getSpritePatch (might rename), image.getSprite2Patch (might rename)

Function Parameters Description Returns
image.create width, height, [format] Creates a patch. format is one of: palette, rgba. Default is palette. patch
image.patchExists name See v.patchExists boolean
image.getPatch name See v.cachePatch patch
image.getSpritePatch sprite, [frame, [rotation, [rollangle]]] See v.getSpritePatch patch, boolean
image.getSprite2Patch skin, sprite2, [super?], [frame, [rotation, [rollangle]]] See v.getSprite2Patch patch, boolean

Adds to patch: is_editable, patch:getPixel, patch:setPixel (might remove), patch:copy, patch:clear

Field Parameters Description Returns
patch.is_editable - Whether the patch can be edited. boolean
patch:getPixel x, y Gets a palette index or RGBA color at x, y. Returns nil on a paletted patch if there is no pixel at x, y number or nil
patch:setPixel x, y, color Sets the pixel at x, y -
patch:copy table, [width, [height, [source_x, [source_y, [source_w, [source_h, [destination_x, [destination_y, [copy_transparent, use_pixel_alpha]]]]]]]]]] OR patch, [source_x, [source_y, [source_w, [source_h, [destination_x, [destination_y, [copy_transparent, use_pixel_alpha]]]]]]]] Copies pixels from a patch or a table from coordinates source_x, source_y sized source_w, source_h into destination_x, destination_y. If the pixels copied originate from a table, the color format must match that of the destination. copy_transparent will copy any transparent pixels from the source, overwriting any opaque pixels. use_pixel_alpha will perform alpha blending on the source pixels that are transparent with the destination pixels (RGBA source only.) -
Edited by Lactozilla

Merge request reports

Loading