Commit Graph

84 Commits

Author SHA1 Message Date
David Capello
b2e4f78b69 clang-format all files 2024-12-16 10:10:34 -03:00
David Capello
df19b09c23 Avoid using tabs in run-tests.sh expected output 2024-12-10 22:42:22 -03:00
Martín Capello
a99161a2d2 Add MaskByColor command lua tests 2024-12-09 19:26:46 -03:00
David Capello
e5faac07b5 Fix regression breaking linked cels on "Merge Down" (fix #4685) 2024-10-03 12:43:26 -03:00
دانتي باولا
b40614ca36
Use FlattenLayers for MergeDownLayerCommand (#4643)
Rework of the cmd::FlattenLayers implementation to accommodates the
'Merge Down' command as a special case.
2024-09-20 17:25:09 -03:00
Gaspar Capello
0f7cac0f0c [lua] Add get/set the foreground/background tile (fix #4403)
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'
2024-09-16 16:19:29 -03:00
Gaspar Capello
e70bbbd369 Add 'x' and 'y' as input parameters to app.command.Paste() 2024-09-05 17:22:12 -03:00
Gaspar Capello
de1fc581f2 Fix app.command.Cut/Paste does not work in --batch mode (fix #4354)
This fix adds support for cut/copy/paste selected areas during
script execution when there isn't UI.
2024-09-05 17:22:12 -03:00
Gaspar Capello
5798e27993 Fix mask color turns to opaque on RGBA->INDEXED conversion (fix #4438)
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
2024-09-04 13:48:56 -03:00
Gaspar Capello
c8f018f2f1
Fix exporting a Sprite Sheet with Group name has different functionality between CLI and Scripting (fix #4456) (#4475)
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"
2024-09-03 20:20:36 -03:00
David Capello
afb8a3d94a [lua] Minor change app.pixelColor -> pc in test 2024-09-03 19:11:14 -03:00
Gaspar Capello
4a91d150af Fix transparent color is possible on opaque sprites (fix #4370)
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.
2024-09-03 19:08:15 -03:00
David Capello
8f7bf09263 Fix doc::blend_image() to support different color modes (fix #4530, fix #4531)
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.
2024-06-11 21:48:57 -03:00
David Capello
7ce9f85b39 [lua] Fix bug comparing integers and floating points (fix #4516)
This bug was introduced in:

  db8284f5fc

We've removed the patch in our updated Lua v5.4.6 branch.
2024-06-03 11:39:16 -03:00
Martín Capello
24e72a36ba Add --play-subtags CLI test 2024-05-28 15:00:22 -03:00
David Capello
6f09bde511 Allow backslash (\) in filenames on Linux and macOS (fix #3936)
We required a new app.os object to skip some tests on non-Windows
platforms when we check for backslashes in app.fs functions.
2024-05-08 14:46:16 -03:00
David Capello
92edd5f700 Add Brush::clone() functions to fix/simplify some Brush-related code
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).
2024-05-03 11:35:36 -03:00
Gaspar Capello
12d8135264 Fix secondary color with custom brush paints the FgColor instead the BgColor (fix #4013)
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.
2024-04-29 17:20:56 -03:00
David Capello
c64756ebde Keep testing loading/saving properties as they are in userdata_codec.lua 2024-02-26 17:44:56 -03:00
David Capello
9f75260d25 Change userdata_codec.lua test to check pre-saved user data properties 2024-02-26 17:40:15 -03:00
David Capello
eeb5be9bed [lua] Fix crashes setting values out of bounds in JSON objects (fix #4166) 2023-11-30 18:40:02 -03:00
David Capello
82375462ae [lua] Fix reported crash setting nil as user data (fix #4187) 2023-11-30 16:10:59 -03:00
Gaspar Capello
8226e5285a Fix Dialog.bounds doesn't work as expected (fix #3898)
Prior to this fix, the 'Dialog:show()' function overrode bounds when
they were defined before the 'show' command.
2023-11-22 18:22:20 -03:00
David Capello
39bdba4a7d Fix assert converting Color{index} to a tile from tilemap.lua test
We must be able to convert a app::Color::IndexType to a tile index.
2023-11-09 16:44:46 -03:00
David Capello
d3a8a10517 [lua] Add test about saving/loading/modifying tilemap w/flags
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.
2023-11-09 16:44:46 -03:00
David Capello
ca8c970c5d Remove ';' chars from lua tests 2023-11-02 14:30:36 -03:00
Martín Capello
3cfa5ef1da [lua] Fix crash when saving tilemap's cel image (fix #4069) 2023-11-02 14:12:55 -03:00
David Capello
557b22a719 [lua] Sprite:newTileset() uses sprite grid size by default (fix #4116) 2023-10-30 13:45:11 -03:00
David Capello
bb60da8c60 [lua] Make Sprite:newTileset(Rectangle) work (fix #4117) 2023-10-30 13:40:12 -03:00
Gaspar Capello
bcbe61c882 Fix border padding on the right and bottom sides not being placed (fix #3993)
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.
2023-09-22 16:33:19 -03:00
Gaspar Capello
aca8621bff Fix pattern Fill does not "Align to Destination" (fix #2528) 2023-09-20 09:56:01 -03:00
David Capello
aeeef8e255 Add suppor for doc::Image row stride size > width size
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).
2023-08-07 15:27:39 -03:00
David Capello
86a50e2e9a [lua] Add native API to decode/encode JSON text (fix #3233)
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).
2023-07-17 09:25:13 -03:00
David Capello
35e64ad2f3 Fix exporting selection to gif/fli/webp files (fix #3827) 2023-07-11 13:33:45 -03:00
Martín Capello
204ee881be Prevent executing the logic for showing an alert when removing all sprite's layers and the UI is unavailable 2023-06-27 15:26:11 -03:00
Martín Capello
5bc432f289 Delete unused tilesets after deleting tilemaps (fix #3876) 2023-06-27 15:24:13 -03:00
David Capello
637d71a276 [lua] Test Image:flip() with sprite and without sprite (#3854) 2023-05-18 13:20:41 -03:00
Gaspar Capello
f3ed22e1a6 [lua] Add Image:flip() 2023-05-18 13:02:07 -03:00
David Capello
66efb35a8c Add test to save UUID properties on .aseprite files 2023-05-08 17:13:44 -03:00
David Capello
948bf98b86 Saving a non-sequence file type (aseprite/gif/webp/fli/etc.) must create all required directories too 2023-05-08 16:22:42 -03:00
Gaspar Capello
afbede3eae Fix webp export to export one tag correctly instead of all frames (fix #3622) 2023-05-08 16:22:31 -03:00
David Capello
622b02294a [lua] Add short field names (fix #3815, fix #3816) 2023-04-19 13:48:15 -03:00
David Capello
1c6e583c87 [lua] Add require() function (fix aseprite/api#10)
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.
2023-04-18 19:41:01 -03:00
David Capello
8ff62f7a5f [lua] Add Uuid tests
Missing file from 636cce6f0d commit
2023-04-18 07:41:32 -03:00
David Capello
2962bb3676 Fix save-as-with-slice CLI test as output files are listed in order 2023-04-14 14:05:51 -03:00
Gaspar Capello
d4d18c99be [lua] Add Image:clear(Rectangle, color) overload (fix #3799)
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>
2023-04-12 15:30:12 -03:00
David Capello
89ced2e557 Add test for -save-as {slice} (#3801, #3802)
Original report: https://community.aseprite.org/t/17692
2023-04-12 15:11:37 -03:00
David Capello
24846eae10 Add z-index property to cels (fix aseprite/Attachment-System#88)
* 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
2023-04-10 19:23:16 -03:00
David Capello
4c1e5d8755 Add a test for -save-as with -filename-format and -split-tags
Test case for the issue commented here: https://github.com/aseprite/aseprite/issues/3733#issuecomment-1494682407
2023-04-03 14:09:03 -03:00
Gaspar Capello
8f515da9f0 Fix 8 Connected Fill escapes grid with "Stop At Grid" checked (fix #3564) 2023-03-28 13:45:33 -03:00