bwidgets/inc/basic_widgets/core/draw.hpp

42 lines
1.5 KiB
C++
Raw Normal View History

2021-08-06 14:22:56 +02:00
#ifndef BWIDGETS_DRAW_HPP
#define BWIDGETS_DRAW_HPP
#include <functional>
2021-08-10 23:48:19 +02:00
#include <memory>
#include <string>
#include <vector>
struct SDL_PixelFormat;
struct SDL_Point;
2022-01-24 16:18:14 +01:00
struct SDL_Rect;
2021-08-06 14:22:56 +02:00
namespace bwidgets
{
2021-08-06 14:22:56 +02:00
class Color;
class Font;
2021-08-06 14:22:56 +02:00
class Renderer;
class Texture;
2021-08-27 01:21:25 +02:00
// Add transparency to color base_color relative to the distance d from
2021-08-23 23:50:14 +02:00
// a limit to produce an AntiAliasing effect.
// d >= 0 → full transparency;
// (aa_pixels) <= d < 0 → smoothsteped transparency gradient;
// d < (aa_pixels) → fully opaque.
2021-08-27 01:21:25 +02:00
[[nodiscard]] auto aa(Color base_color, int aa_pixels, float d) noexcept -> Color;
2022-01-24 16:18:14 +01:00
void fill_rect_gradient(Renderer&, const SDL_Rect& r, Color start, Color end,
int steps = 4);
2021-08-23 23:50:14 +02:00
// Render a filled circle texture of color c and diameter resolution with
// aa_pixels used for antialiasing.
[[nodiscard]] auto filled_circle(Color c, int resolution, const Renderer&,
int aa_pixels = 3) -> std::shared_ptr<Texture>;
[[nodiscard]] auto render_text(const std::vector<std::string>&, const Color&, Font&,
const Renderer&) -> std::shared_ptr<Texture>;
2021-08-23 23:50:14 +02:00
// Set the color of every pixels of a Texture using the passed function to compute
// pixel color.
void
set_pixels_color(Texture*,
const std::function<uint32_t(SDL_Point, const SDL_PixelFormat&)>&);
}
#endif