Porytiles
Loading...
Searching...
No Matches
tiles_png_workspace.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <optional>
5#include <vector>
6
11
12namespace porytiles2 {
13
40 public:
57 explicit TilesPngWorkspace(std::size_t capacity);
58
91 explicit TilesPngWorkspace(const Image<IndexPixel> &img, std::size_t capacity);
92
121 [[nodiscard]] bool insert_tile(const CanonicalPixelTile<IndexPixel> &tile);
122
144 [[nodiscard]] std::optional<std::size_t> first_occurrence_of(const CanonicalPixelTile<IndexPixel> &tile) const;
145
162 [[nodiscard]] CanonicalPixelTile<IndexPixel> tile_at(std::size_t index) const;
163
184 [[nodiscard]] Image<IndexPixel> export_canonical_image() const;
185
207 [[nodiscard]] Image<IndexPixel> export_original_image() const;
208
222 [[nodiscard]] bool at_capacity() const;
223
233 [[nodiscard]] std::size_t capacity() const
234 {
235 return capacity_;
236 }
237
238 private:
239 std::vector<CanonicalPixelTile<IndexPixel>> tiles_;
240 std::map<PixelTile<IndexPixel>, std::vector<std::size_t>> canonical_forms_;
241 std::size_t cursor_;
242 std::size_t capacity_;
243};
244
245} // namespace porytiles2
A PixelTile representation that stores the canonical (lexicographically minimal) orientation among al...
A template for two-dimensional images with arbitrarily typed pixel values.
Definition image.hpp:24
A workspace for managing canonical IndexPixel tiles destined for tiles.png output.
bool insert_tile(const CanonicalPixelTile< IndexPixel > &tile)
Attempts to insert a non-transparent tile into the workspace at the current cursor position.
bool at_capacity() const
Checks if the workspace has reached capacity and can no longer accept new tile insertions.
std::optional< std::size_t > first_occurrence_of(const CanonicalPixelTile< IndexPixel > &tile) const
Finds the first occurrence index of a given canonical tile in the workspace.
Image< IndexPixel > export_canonical_image() const
Exports the workspace tiles to an Image<IndexPixel> in canonical form (tiles.png format).
CanonicalPixelTile< IndexPixel > tile_at(std::size_t index) const
Retrieves the canonical tile at the specified index in the workspace.
Image< IndexPixel > export_original_image() const
Exports the workspace tiles to an Image<IndexPixel> in original (pre-canonicalization) form.
std::size_t capacity() const
Returns the maximum number of tiles this workspace can hold.