Commit Graph

61 Commits

Author SHA1 Message Date
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
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
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
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
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
Gaspar Capello
8f515da9f0 Fix 8 Connected Fill escapes grid with "Stop At Grid" checked (fix #3564) 2023-03-28 13:45:33 -03:00
Gaspar Capello
637632eafb [lua] Add blend modes to Image:drawImage() 2023-03-27 20:31:58 -03:00
David Capello
88296340a6 [lua] Add Size:union() function 2023-03-13 16:03:03 -03:00
Martín Capello
47a1c407c3 Update the way vectors are serialized to support mixed elements types 2023-02-22 12:51:51 -03:00
David Capello
64ce25fae2 Add property to disable the standard tilemap UI
Added a Sprite.tileManagementPlugin property for plugins that want to
replace the standard tilemap/tileset interface. This includes a new
external file field in .aseprite files to specify that the sprite
tiles are controlled by a specific plugin.

Once this property is set, the standard tilemap/tileset modes
selectors will disappear and the only way to make then available will
be setting this property to nil/empty string again.

Fix https://github.com/aseprite/Attachment-System/issues/21
2023-02-15 18:55:21 -03:00
David Capello
a5a1d22705 Add some tests to encode/decode tile properties 2023-02-13 17:21:42 -03:00
David Capello
faabacdd39 [lua] Fix undo/redo of tileset properties changes (name/baseIndex) 2023-01-13 19:16:15 -03:00
David Capello
11a3e634b1 Fix bug undoing tileset deletion wasn't restoring its name correctly
Actually it looks like a long-standing bug in the write/read_tileset()
functions where tileset names aren't saved (so another bug fixed with
this change is that restoring a tileset from a crashes session/file,
will restore the tileset name correctly).
2023-01-13 18:54:31 -03:00
Gaspar Capello
f82ab4f3d9 Fix tilemapMode parameter of a few useTool methods on tilemap.lua tests 2023-01-12 09:29:07 -03:00
Gaspar Capello
0ab6f9681d Tests for Sprite:newTile() and Sprite:deleteTile() methods 2023-01-12 09:28:33 -03:00
Martín Capello
7e16b49644 Add tileset creation/deletion tests in lua 2023-01-12 09:25:43 -03:00
David Capello
0387337100 Test that saving empty property maps corrupt the .aseprite file 2023-01-09 15:54:30 -03:00
David Capello
81b2507bb6 [lua] Add Tileset:tile(tileIndex) API to get tile image/data/properties (fix #3653)
This should replace the old Tileset:getTile(tileIndex) which returns
only the image.
2023-01-06 19:50:04 -03:00
Martín Capello
6534d37b40 Add custom properties serialization/deserialization lua tests 2023-01-06 19:28:02 -03:00
David Capello
d590d3f39a Add nullptr_t to doc::UserData::Variant to fix bug when undoing an previously unexistent property 2023-01-06 14:36:51 -03:00
David Capello
645605305f [lua] Add undo information when we modify user data properties 2023-01-03 11:14:19 -03:00
David Capello
427efef257 [lua] Add possibility to set the whole properties object 2023-01-03 09:00:36 -03:00
David Capello
b9537dbbe0 [lua] Add object.properties("extID") syntax to get extension properties 2023-01-03 08:34:14 -03:00
David Capello
9138592e98 [lua] Add support to set/get tables (arrays/maps) into user properties 2023-01-02 19:51:07 -03:00