bwidgets/inc/basic_widgets/core/draw.hpp
Andrea Blankenstijn 6149c48664 default fonts in theme, custom with FontHandler.
fix input highlight.
render multiline text.
remove default theme singleton.
scrollable area texture alignment.
2022-02-01 19:14:51 +01:00

42 lines
1.5 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef BWIDGETS_DRAW_HPP
#define BWIDGETS_DRAW_HPP
#include <functional>
#include <memory>
#include <string>
#include <vector>
struct SDL_PixelFormat;
struct SDL_Point;
struct SDL_Rect;
namespace bwidgets
{
class Color;
class Font;
class Renderer;
class Texture;
// Add transparency to color base_color relative to the distance d from
// a limit to produce an AntiAliasing effect.
// d >= 0 → full transparency;
// (aa_pixels) <= d < 0 → smoothsteped transparency gradient;
// d < (aa_pixels) → fully opaque.
[[nodiscard]] auto aa(Color base_color, int aa_pixels, float d) noexcept -> Color;
void fill_rect_gradient(Renderer&, const SDL_Rect& r, Color start, Color end,
int steps = 4);
// 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>;
// 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