tgbotxx 1.2.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
BackgroundFill.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
12 BackgroundFill() = default;
13 explicit BackgroundFill(const nl::json& json) {
15 }
16 virtual ~BackgroundFill() = default;
17
19 std::string type;
20
21 [[nodiscard]] virtual nl::json toJson() const {
22 nl::json json = nl::json::object();
24 return json;
25 }
26
27 virtual void fromJson(const nl::json& json) {
28 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
29 }
30 };
31
36 type = "solid";
37 }
38 explicit BackgroundFillSolid(const nl::json& json) {
40 }
41
43 std::int32_t color{};
44
45 nl::json toJson() const override {
46 nl::json json = BackgroundFill::toJson();
48 return json;
49 }
50
51 void fromJson(const nl::json& json) override {
53 OBJECT_DESERIALIZE_FIELD(json, "color", color, 0, false);
54 }
55 };
56
61 type = "gradient";
62 }
66
68 std::int32_t topColor{};
69
71 std::int32_t bottomColor{};
72
74 std::int32_t rotationAngle{};
75
76 nl::json toJson() const override {
77 nl::json json = BackgroundFill::toJson();
79 OBJECT_SERIALIZE_FIELD(json, "bottom_color", bottomColor);
80 OBJECT_SERIALIZE_FIELD(json, "rotation_angle", rotationAngle);
81 return json;
82 }
83
84 void fromJson(const nl::json& json) override {
86 OBJECT_DESERIALIZE_FIELD(json, "top_color", topColor, 0, false);
87 OBJECT_DESERIALIZE_FIELD(json, "bottom_color", bottomColor, 0, false);
88 OBJECT_DESERIALIZE_FIELD(json, "rotation_angle", rotationAngle, 0, false);
89 }
90 };
91
96 type = "freeform_gradient";
97 }
101
103 std::vector<std::int32_t> colors;
104
105 nl::json toJson() const override {
106 nl::json json = BackgroundFill::toJson();
108 return json;
109 }
110
111 void fromJson(const nl::json& json) override {
113 OBJECT_DESERIALIZE_FIELD(json, "colors", colors, {}, false);
114 }
115 };
116
117}
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:46
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
The background is a freeform gradient that rotates after every message in the chat....
std::vector< std::int32_t > colors
A list of 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format.
BackgroundFillFreeformGradient(const nl::json &json)
void fromJson(const nl::json &json) override
The background is a gradient fill. https://core.telegram.org/bots/api#backgroundfillgradient.
BackgroundFillGradient(const nl::json &json)
std::int32_t bottomColor
Bottom color of the gradient in the RGB24 format.
nl::json toJson() const override
void fromJson(const nl::json &json) override
std::int32_t topColor
Top color of the gradient in the RGB24 format.
std::int32_t rotationAngle
Clockwise rotation angle of the background fill in degrees; 0-359.
This object describes the way a background is filled based on the selected colors....
virtual nl::json toJson() const
virtual ~BackgroundFill()=default
std::string type
Type of the background fill, one of "solid", "gradient", "freeform_gradient".
BackgroundFill(const nl::json &json)
virtual void fromJson(const nl::json &json)
The background is filled using the selected solid color. https://core.telegram.org/bots/api#backgroun...
std::int32_t color
The color of the background fill in the RGB24 format.
void fromJson(const nl::json &json) override
BackgroundFillSolid(const nl::json &json)
nl::json toJson() const override