tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
StoryAreaPosition.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
5
9 StoryAreaPosition() = default;
10 explicit StoryAreaPosition(const nl::json& json) {
11 fromJson(json);
12 }
13
15 float xPercentage{};
16
18 float yPercentage{};
19
22
25
28
31
34 nl::json toJson() const {
35 nl::json json = nl::json::object();
36 OBJECT_SERIALIZE_FIELD(json, "x_percentage", xPercentage);
37 OBJECT_SERIALIZE_FIELD(json, "y_percentage", yPercentage);
38 OBJECT_SERIALIZE_FIELD(json, "width_percentage", widthPercentage);
39 OBJECT_SERIALIZE_FIELD(json, "height_percentage", heightPercentage);
40 OBJECT_SERIALIZE_FIELD(json, "rotation_angle", rotationAngle);
41 OBJECT_SERIALIZE_FIELD(json, "corner_radius_percentage", cornerRadiusPercentage);
42 return json;
43 }
44
46 void fromJson(const nl::json& json) {
47 OBJECT_DESERIALIZE_FIELD(json, "x_percentage", xPercentage, 0.0f, false);
48 OBJECT_DESERIALIZE_FIELD(json, "y_percentage", yPercentage, 0.0f, false);
49 OBJECT_DESERIALIZE_FIELD(json, "width_percentage", widthPercentage, 0.0f, false);
50 OBJECT_DESERIALIZE_FIELD(json, "height_percentage", heightPercentage, 0.0f, false);
51 OBJECT_DESERIALIZE_FIELD(json, "rotation_angle", rotationAngle, 0.0f, false);
52 OBJECT_DESERIALIZE_FIELD(json, "corner_radius_percentage", cornerRadiusPercentage, 0.0f, false);
53 }
54 };
55
56}
#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
Describes the position of a clickable area within a story https://core.telegram.org/bots/api#storyare...
float cornerRadiusPercentage
The radius of the rectangle corner rounding, as a percentage of the media width.
float widthPercentage
The width of the area's rectangle, as a percentage of the media width.
float yPercentage
The ordinate of the area's center, as a percentage of the media height.
StoryAreaPosition(const nl::json &json)
float heightPercentage
The height of the area's rectangle, as a percentage of the media height.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
float xPercentage
The abscissa of the area's center, as a percentage of the media width.
StoryAreaPosition()=default
nl::json toJson() const
Serializes this object to JSON.
float rotationAngle
The clockwise rotation angle of the rectangle, in degrees; 0-360.