Skip to content

File Opacity.hpp

File List > Components > Opacity.hpp

Go to the documentation of this file

#ifndef ENGINE_COMPONENTS_OPACITY_HPP_
#define ENGINE_COMPONENTS_OPACITY_HPP_

#include <algorithm>

namespace Engine {

struct Opacity {
    float alpha = 1.0f;

    bool inheritToChildren = true;

    static Opacity Create(float alpha = 1.0f, bool inheritToChildren = true) {
        Opacity opacity;
        opacity.alpha = std::clamp(alpha, 0.0f, 1.0f);
        opacity.inheritToChildren = inheritToChildren;
        return opacity;
    }
};

} // namespace Engine

#endif // ENGINE_COMPONENTS_OPACITY_HPP_