1// Aseprite
2// Copyright (C) 2019-2021 Igara Studio S.A.
3// Copyright (C) 2001-2016 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifndef APP_UTIL_CEL_OPS_H_INCLUDED
9#define APP_UTIL_CEL_OPS_H_INCLUDED
10#pragma once
11
12#include "app/tilemap_mode.h"
13#include "app/tileset_mode.h"
14#include "doc/color.h"
15#include "doc/frame.h"
16#include "doc/image_ref.h"
17#include "gfx/point.h"
18#include "gfx/region.h"
19
20#include <functional>
21#include <vector>
22
23namespace doc {
24 class Cel;
25 class Layer;
26 class LayerTilemap;
27 class PalettePicks;
28 class Sprite;
29 class Tileset;
30}
31
32namespace app {
33 class CmdSequence;
34
35 typedef std::function<doc::ImageRef(const doc::ImageRef& origTile,
36 const gfx::Rect& tileBoundsInCanvas)> GetTileImageFunc;
37
38 void create_region_with_differences(const doc::Image* a,
39 const doc::Image* b,
40 const gfx::Rect& bounds,
41 gfx::Region& output);
42
43 // Creates a new image of the given cel
44 doc::ImageRef crop_cel_image(
45 const doc::Cel* cel,
46 const doc::color_t bgcolor);
47
48 // The "cmds" is used in case that new tiles must be added in the
49 // dstLayer tilesets.
50 doc::Cel* create_cel_copy(
51 CmdSequence* cmds,
52 const doc::Cel* srcCel,
53 const doc::Sprite* dstSprite,
54 doc::Layer* dstLayer,
55 const doc::frame_t dstFrame);
56
57 // Draws an image creating new tiles.
58 void draw_image_into_new_tilemap_cel(
59 CmdSequence* cmds,
60 doc::LayerTilemap* dstLayer,
61 doc::Cel* dstCel,
62 const doc::Image* srcImage,
63 const gfx::Point& gridOrigin,
64 const gfx::Point& srcImagePos,
65 const gfx::Rect& canvasBounds,
66 doc::ImageRef& newTilemap);
67
68 void modify_tilemap_cel_region(
69 CmdSequence* cmds,
70 doc::Cel* cel,
71 doc::Tileset* previewTileset, // Temporary tileset that can be used for preview
72 const gfx::Region& region,
73 const TilesetMode tilesetMode,
74 const GetTileImageFunc& getTileImage,
75 const gfx::Region& forceRegion = gfx::Region());
76
77 void clear_mask_from_cel(
78 CmdSequence* cmds,
79 doc::Cel* cel,
80 const TilemapMode tilemapMode,
81 const TilesetMode tilesetMode);
82
83 void move_tiles_in_tileset(
84 CmdSequence* cmds,
85 doc::Tileset* tileset,
86 doc::PalettePicks& picks,
87 int& currentEntry,
88 int beforeIndex);
89
90 void copy_tiles_in_tileset(
91 CmdSequence* cmds,
92 doc::Tileset* tileset,
93 doc::PalettePicks& picks,
94 int& currentEntry,
95 int beforeIndex);
96
97} // namespace app
98
99#endif
100