Simple GUI Library
shadow.h
Go to the documentation of this file.
1/**
2 * @author Nikita Mochalov (github.com/tralf-strues)
3 * @file shadow.h
4 * @date 2021-11-22
5 *
6 * @copyright Copyright (c) 2021
7 */
8
9#pragma once
10
11#include "sml/math/blur.h"
12#include "sml/graphics_wrapper/texture.h"
13
14namespace Sgl
15{
17 {
18 public:
19 friend class Shadow;
20
21 public:
22 ShadowSpecification(const Sml::Vec2i& offset, const Sml::Vec2f& scale,
23 int32_t blurRadius, Sml::Color color = Sml::COLOR_BLACK);
24
26
27 const Sml::Vec2i& getOffset() const;
28 const Sml::Vec2f& getScale() const;
29 int32_t getBlurRadius() const;
30 Sml::Color getColor() const;
31
32 private:
33 Sml::Vec2i m_Offset = {0, 0};
34 Sml::Vec2f m_Scale = {1, 1};
35 Sml::Kernel* m_BlurKernel = nullptr;
36 Sml::Color m_Color = Sml::COLOR_BLACK;
37 };
38
39 class Shadow
40 {
41 public:
42 Shadow(const ShadowSpecification* specification = nullptr);
43
44 public:
45 ~Shadow();
46
47 void update(const Sml::Texture* srcTexture, const Sml::Rectangle<int32_t>& objectRegion);
48 void render(const Sml::Rectangle<int32_t>& object, const Sml::Rectangle<int32_t>& targetRegion);
49
50 Sml::Texture* getTexture() const;
51
52 const ShadowSpecification* getSpecification() const;
53 void setSpecification(const ShadowSpecification* specification);
54
55 private:
56 const ShadowSpecification* m_Specification = nullptr;
57 Sml::Texture* m_Texture = nullptr;
58 };
59}