mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-12 03:33:41 +00:00
79 lines
2.9 KiB
C++
79 lines
2.9 KiB
C++
#ifndef Canvas_h
|
|
#define Canvas_h
|
|
|
|
#include <LottieCpp/LottieCpp.h>
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
#include <cassert>
|
|
|
|
namespace lottieRendering {
|
|
|
|
class Image {
|
|
public:
|
|
virtual ~Image() = default;
|
|
};
|
|
|
|
class Gradient {
|
|
public:
|
|
Gradient(std::vector<lottie::Color> const &colors, std::vector<float> const &locations) :
|
|
_colors(colors),
|
|
_locations(locations) {
|
|
assert(_colors.size() == _locations.size());
|
|
}
|
|
|
|
std::vector<lottie::Color> const &colors() const {
|
|
return _colors;
|
|
}
|
|
|
|
std::vector<float> const &locations() const {
|
|
return _locations;
|
|
}
|
|
|
|
private:
|
|
std::vector<lottie::Color> _colors;
|
|
std::vector<float> _locations;
|
|
};
|
|
|
|
enum class BlendMode {
|
|
Normal,
|
|
DestinationIn,
|
|
DestinationOut
|
|
};
|
|
|
|
class Canvas {
|
|
public:
|
|
virtual ~Canvas() = default;
|
|
|
|
virtual int width() const = 0;
|
|
virtual int height() const = 0;
|
|
|
|
virtual std::shared_ptr<Canvas> makeLayer(int width, int height) = 0;
|
|
|
|
virtual void saveState() = 0;
|
|
virtual void restoreState() = 0;
|
|
|
|
virtual void fillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, lottie::Color const &color) = 0;
|
|
virtual void linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) = 0;
|
|
virtual void radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) = 0;
|
|
|
|
virtual void strokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, lottie::Color const &color) = 0;
|
|
virtual void linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) = 0;
|
|
virtual void radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) = 0;
|
|
|
|
virtual void fill(lottie::CGRect const &rect, lottie::Color const &fillColor) = 0;
|
|
virtual void setBlendMode(BlendMode blendMode) = 0;
|
|
|
|
virtual void setAlpha(float alpha) = 0;
|
|
|
|
virtual void concatenate(lottie::CATransform3D const &transform) = 0;
|
|
virtual lottie::CATransform3D currentTransform() = 0;
|
|
|
|
virtual void draw(std::shared_ptr<Canvas> const &other, lottie::CGRect const &rect) = 0;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|
|
|