SVG spritesheets: pack, merge, rasterize
Packing an SVG sheet makes a new SVG holding its drawing once (as a symbol), each region a clipped view of it at its new place; merging makes an SVG whenever any sheet is one, with PNG sheets embedded as images (the merged sheet's file name takes the matching extension). Both go through Image::compose, which also does the pixel versions, so merge_append is gone. Vector sheets save as their SVG (autosaves too, and images load as PNG or SVG by content), and their asset key includes the SVG. Rasterize in the Spritesheets menu turns selected SVG sheets into PNGs beside them, with a toast for each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bec89bf48f
commit
5f01e8065d
14 files changed
+316
-82
No files matched your search
+13
-1
@@ -18,6 +18,17 @@ namespace anm2ed::resource::image
|
||||
|
||||
namespace anm2ed::resource
|
||||
{
|
||||
class Image;
|
||||
|
||||
// A block of an image placed at `destination`, for composing images.
|
||||
struct ImagePart
|
||||
{
|
||||
const Image* image{};
|
||||
glm::ivec2 source{};
|
||||
glm::ivec2 size{};
|
||||
glm::ivec2 destination{};
|
||||
};
|
||||
|
||||
// CPU-side RGBA pixels. uid changes whenever the pixels do, so GPU copies can be cached by it. A vector image keeps
|
||||
// its SVG and is drawn at `scale` pixels per SVG unit; it can be drawn again at any scale, and isn't edited.
|
||||
class Image
|
||||
@@ -42,7 +53,8 @@ namespace anm2ed::resource
|
||||
size_t pixel_size_get() const;
|
||||
bool write_png(const std::filesystem::path&) const;
|
||||
static bool write_pixels_png(const std::filesystem::path&, glm::ivec2, const uint8_t*);
|
||||
static Image merge_append(const Image&, const Image&, bool);
|
||||
bool write(const std::filesystem::path&) const;
|
||||
static Image compose(const std::vector<ImagePart>&, glm::ivec2, bool);
|
||||
void paste(const Image&, glm::ivec2);
|
||||
Image region_get(glm::ivec2, glm::ivec2) const;
|
||||
glm::vec4 pixel_read(glm::vec2) const;
|
||||
|
||||
Reference in new issue
Block a user