tgbotxx 1.1.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) {
14 _fromJson(json);
15 }
16 virtual ~BackgroundFill() = default;
17
19 std::string type;
20
21 virtual nl::json toJson() const {
22 nl::json json = nl::json::object();
23 OBJECT_SERIALIZE_FIELD(json, "type", type);
24 return json;
25 }
26
27 virtual void fromJson(const nl::json& json) {
28 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
29 }
30
31 private:
32 void _fromJson(const nl::json& json) {
33 fromJson(json);
34 }
35 };
36
43 explicit BackgroundFillSolid(const nl::json& json) : BackgroundFill(json) {
44 BackgroundFill::type = "solid";
45 }
46
48 std::int32_t color{};
49
50 nl::json toJson() const override {
51 nl::json json = BackgroundFill::toJson();
52 OBJECT_SERIALIZE_FIELD(json, "color", color);
53 return json;
54 }
55
56 void fromJson(const nl::json& json) override {
58 OBJECT_DESERIALIZE_FIELD(json, "color", color, 0, false);
59 }
60 };
61
68 explicit BackgroundFillGradient(const nl::json& json) : BackgroundFill(json) {
69 BackgroundFill::type = "gradient";
70 }
71
73 std::int32_t topColor{};
74
76 std::int32_t bottomColor{};
77
79 std::int32_t rotationAngle{};
80
81 nl::json toJson() const override {
82 nl::json json = BackgroundFill::toJson();
83 OBJECT_SERIALIZE_FIELD(json, "top_color", topColor);
84 OBJECT_SERIALIZE_FIELD(json, "bottom_color", bottomColor);
85 OBJECT_SERIALIZE_FIELD(json, "rotation_angle", rotationAngle);
86 return json;
87 }
88
89 void fromJson(const nl::json& json) override {
91 OBJECT_DESERIALIZE_FIELD(json, "top_color", topColor, 0, false);
92 OBJECT_DESERIALIZE_FIELD(json, "bottom_color", bottomColor, 0, false);
93 OBJECT_DESERIALIZE_FIELD(json, "rotation_angle", rotationAngle, 0, false);
94 }
95 };
96
101 BackgroundFill::type = "freeform_gradient";
102 }
103 explicit BackgroundFillFreeformGradient(const nl::json& json) : BackgroundFill(json) {
104 BackgroundFill::type = "freeform_gradient";
105 }
106
108 std::vector<std::int32_t> colors;
109
110 nl::json toJson() const override {
111 nl::json json = BackgroundFill::toJson();
112 OBJECT_SERIALIZE_FIELD(json, "colors", colors);
113 return json;
114 }
115
116 void fromJson(const nl::json& json) override {
118 OBJECT_DESERIALIZE_FIELD(json, "colors", colors, {}, false);
119 }
120 };
121
122}
#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
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