It's now possible to get/set the selected foreground/background tile
index. Example of use:
app.fgTile = 1 -- the primary tile is '1'
print(app.fgTile) -- this will show '1'
app.fgTile = 0 -- the primery tile is 'no tile'
print(app.fgTile) -- this will show '0'
app.bgTile = 2 -- the secondary tile is '2'
Original issue title: When using a background layer, switching to
Indexed Color Mode fills all layer bounding rectangles with
Color 0.
Conditions to reproduce the original issue:
- Opaque RGBA sprite, i.e. the bottom layer is 'Background'.
- There is a second layer with an ellipse (for example).
- There is a mask color #000000 alpha=0 is in the palette.
- The mask color index is greater and not equal than 0.
- Go to Sprite > Color Mode > Indexed.
Result: the transparent color of the second layer will change to
index color = 0 (usually black).
Also added test for RGBA->INDEXED conversion
Before this fix, the lua command:
app.command.ExportSpriteSheet
could not process a layer within a group when the layer name
was expressed using the layer hierarchy path, for example:
layer = "Group1/Layer1"
To reproduce the error before this fix on RGBA/Grayscale Color Mode:
- New 100x100 RGBA/Grayscale opaque sprite (white background).
- Draw something with some gray color in the palette.
- Keep the selected gray color as primary color.
- Configure as secondary color the mask color (#000000 alpha=0).
- Pick 'eraser' tool and erase over the gray color with right click.
- Result: The sprite doesn't look more opaque, which is wrong. Also,
if we export this sprite, the transparent parts will turn black.
A similar problem occurs in Indexed Color Mode, but getting a
transparent color in a Background sprite is inevitable if the color of
a palette entry is transparent or semi-transparent, since the index
must be set as is. This could be fixed in the future at the
render stage, however, this could lead to other perceived
inconsistencies. For now it'll be left as is.
Original issue description:
Downloaded PNG in RGB mode fails to support transparency: erase
uses secondary color and export PNG replaces transparent color
with black
Added tests for 'eraser' in 'Replace Color Mode'
To make the eraser work in 'Replace Color Mode' within the tests,
was implemented the possibility of using the right button in
the creation of the point vector.
During testing with UI available it was observed that the 'bg' color
was copied from the 'fg'. Changed this to be compatible with the way
the default value of 'fg' is assigned when it is not specified.
This last modification resulted in errors during 'tilemap.lua' due to
incompatibility of the type of 'bg' color. This was corrected
considering the color type of 'fg' color.
Furthermore, it was found that the command 'app.range.tiles = { 1 }'
did not finish assigning the tile picks to the activeSite,
then 'assert(1, #app.range.tiles)' was failing. This was fixed too.
The code was refactored moving the BlenderHelper class from "render"
to "doc", and now doc::blend_image() supports blending different color
modes.
Some work is still needed to work with grayscale images correctly.
This refactor includes:
- In Lua now we can clone a custom brush with Brush(Image) and the new
brush doesn't share the image with the original one (added a new test
for this).
- Avoid creating extra images when it's not needed using
Brush::cloneWithExistingImages() (we can inject existing images in
the brush itself).
- Delete Brush-copy contructor & assign operator to use
Brush::clone() functions instead (which are more explicit).
- Some code from 12d8135264 (#4023)
reverted to avoid recreating brushes on left-click or in the brush
preview, i.e. moving the mouse (#4013 refers only to right-click, so
only on right-click we have to adjust the custom brush).
Before this fix to change the main color of the image brush,
it was necessary to choose a new color from the palette.
The secondary color can now also be used.
Also added some tests for image brushes.
Something interesting is that Image:drawPixel() must ask for a rehash
to the tileset when the tile is modified, maybe we can find a better
way to handle this in the future.
Prior to this fix, border padding was clipped to the edge of sprites
on the right and bottom in all export sprite sheet types.
This commit includes tests for 'Export Sprite Sheet' command using
shape padding, border padding, inner padding with 'Packed' sheet type
+ 'Trim Cels' = true.
This patch solves several problems introducing the possibility to
specify a row stride bigger than the width (visible pixels) on each
image row. Useful in case that we want to align the initial pixel
address of each row (if DOC_USE_ALIGNED_PIXELS is defined).
This allows us to use some SIMD intrinsics (e.g. SSE2) for some image
functions in the future (right now implemented only in the new
is_same_image_simd_templ() for is_same_image()).
Anyway to avoid breaking some existing code, by default we'll still
keep the old behavior: row stride bytes = width bytes (so
DOC_USE_ALIGNED_PIXELS is undefined).
New json.decode(jsonText) and json.encode(luaTable) functions.
In this way we don't depend on third-party libraries to decode/encode
JSON text which is a quite common task (in tests and export scripts).
This is the first attempt to finally implement the require() function
on Lua. The main problem was how to solve conflicts between plugins
that use the same library name. Here we separate each plugin like in a
namespace, so require(name) inside a plugin will save the module in
_LOADED["pluginName/libraryName"] to avoid conflicts with other
libraryName from other plugins.
We can use:
Image:clear()
Image:clear(color)
Image:clear(rectangle)
Image:clear(rectangle, color)
If the color is not specified it will be the transparent color of the
image.
Co-authored-by: David Capello <david@igara.com>
* Now a Cel has a z-index property to change the order of layers per frame
* A new doc::RenderPlan class can calculate the order of cels to be rendered
* z-index is saved as a int16_t in the .aseprite files
* This new field can be set/get from Lua with Cel.zIndex