Draw options
micro::draw_options configures how a texture is drawn. All options have
sensible defaults — use the fluent API to configure only what you need.
struct draw_options {
constexpr draw_options& tint(color c) noexcept;
constexpr draw_options& scale(float s) noexcept;
constexpr draw_options& flip(micro::flip f) noexcept;
constexpr draw_options& rotation(micro::rotation r) noexcept;
constexpr color tint() const noexcept;
constexpr float scale() const noexcept;
constexpr micro::flip flip() const noexcept;
constexpr micro::rotation rotation() const noexcept;
};
Use method chaining to configure options:
// No options — draw as-is:
rend.draw(tex, {10.f, 20.f});
// Tinted red at 2× scale:
rend.draw(tex, {10.f, 20.f}, draw_options{}.tint(color::red).scale(2.f));
// Sprite sheet frame, flipped horizontally:
rend.draw(tex, {0, 0, 16, 16}, {10.f, 20.f}, draw_options{}.flip(flip::horizontal));
flip
Controls mirroring of the drawn sprite:
| Value | Effect |
|---|---|
flip::none |
No mirroring |
flip::horizontal |
Mirror left–right |
flip::vertical |
Mirror top–bottom |
flip::both |
Mirror both axes |
rotation
Clockwise rotation in 90° steps, implemented as UV permutation — no trigonometry, suitable for pixel-perfect sprite work:
| Value | Effect |
|---|---|
rotation::none |
No rotation |
rotation::cw90 |
90° clockwise |
rotation::cw180 |
180° |
rotation::cw270 |
270° clockwise |
tint
A multiplicative color applied to every pixel of the texture. color::white
(the default) leaves the texture unchanged. Use any other color to tint or
apply transparency:
// 50% transparent draw:
rend.draw(tex, pos, draw_options{}.tint({255, 255, 255, 128}));
// Flash red on damage:
rend.draw(tex, pos, draw_options{}.tint(color::red));
scale
Uniform scale applied around the top-left corner of the destination position:
// Draw at double size:
rend.draw(tex, pos, draw_options{}.scale(2.f));