Files
anm2ed/src/model/draw.hpp
T
shweetandClaude Opus 5.5 a917d8ae97 SVG spritesheets
An .svg spritesheet loads through lunasvg (now part of the core library) at
one pixel per SVG unit, so regions, crops and picking work as for PNGs. The
preview, renders and CLI draw it again, cached per power-of-two zoom level up
to 8x, so it stays sharp when zoomed or scaled. Its pixels aren't edited
(pencil, eraser, pack and merge leave it alone, and Save skips it), and the
Isaac warning counts SVG sheets since the game can't load them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 17:41:57 -04:00

59 lines
1.6 KiB
C++

#pragma once
#include <functional>
#include <vector>
#include "model.hpp"
// What an animation draws at a time, as plain data: every canvas (preview, render, about) draws from this list.
namespace anm2ed::model
{
enum class DrawType
{
ROOT,
GROUP_ROOT,
LAYER,
NULL_
};
// An onion-skin sample: a time offset, or (when sampling by index) an offset in each track's frames.
struct DrawSample
{
float timeOffset{};
int indexOffset{};
};
// The document a library id of a document (the one drawn, or a library) points at; nullptr when not loaded.
using LibraryGet = std::function<const Model*(const Model&, int)>;
struct DrawOptions
{
float time{};
bool isRootTransform{};
bool isIndexSampled{};
std::vector<DrawSample> samples{};
LibraryGet library_get{};
};
// An item's frame at a time; `parent` is the transform of its root and group root when root transforms are shown
// (whose tint and color offset are then folded into a layer's frame). `sample` indexes the samples, -1 for now.
// A layer draw shows spritesheet `spritesheetId` of `source`; an animation layer's child animation draws as its
// layers' draws, with the animation layer's id and transform.
struct Draw
{
DrawType type{};
int id{-1};
int groupType{NONE};
int sample{-1};
float time{};
Frame frame{};
glm::mat4 parent{1.0f};
const Model* source{};
int spritesheetId{-1};
};
glm::mat4 draw_quad_model_get(const Draw&);
float draw_scale_get(const Draw&);
std::vector<Draw> animation_draws_get(const Model&, const Animation&, const DrawOptions&);
}