This repository has been archived by the owner on Jul 3, 2022. It is now read-only.
forked from Arman92/go-tdlib
/
vectorPathCommand.go
109 lines (90 loc) · 3.82 KB
/
vectorPathCommand.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package tdlib
import (
"encoding/json"
"fmt"
)
// VectorPathCommand Represents a vector path command
type VectorPathCommand interface {
GetVectorPathCommandEnum() VectorPathCommandEnum
}
// VectorPathCommandEnum Alias for abstract VectorPathCommand 'Sub-Classes', used as constant-enum here
type VectorPathCommandEnum string
// VectorPathCommand enums
const (
VectorPathCommandLineType VectorPathCommandEnum = "vectorPathCommandLine"
VectorPathCommandCubicBezierCurveType VectorPathCommandEnum = "vectorPathCommandCubicBezierCurve"
)
func unmarshalVectorPathCommand(rawMsg *json.RawMessage) (VectorPathCommand, error) {
if rawMsg == nil {
return nil, nil
}
var objMap map[string]interface{}
err := json.Unmarshal(*rawMsg, &objMap)
if err != nil {
return nil, err
}
switch VectorPathCommandEnum(objMap["@type"].(string)) {
case VectorPathCommandLineType:
var vectorPathCommandLine VectorPathCommandLine
err := json.Unmarshal(*rawMsg, &vectorPathCommandLine)
return &vectorPathCommandLine, err
case VectorPathCommandCubicBezierCurveType:
var vectorPathCommandCubicBezierCurve VectorPathCommandCubicBezierCurve
err := json.Unmarshal(*rawMsg, &vectorPathCommandCubicBezierCurve)
return &vectorPathCommandCubicBezierCurve, err
default:
return nil, fmt.Errorf("Error UnMarshaling, unknown type:" + objMap["@type"].(string))
}
}
// VectorPathCommandLine A straight line to a given point
type VectorPathCommandLine struct {
tdCommon
EndPoint *Point `json:"end_point"` // The end point of the straight line
}
// MessageType return the string telegram-type of VectorPathCommandLine
func (vectorPathCommandLine *VectorPathCommandLine) MessageType() string {
return "vectorPathCommandLine"
}
// NewVectorPathCommandLine creates a new VectorPathCommandLine
//
// @param endPoint The end point of the straight line
func NewVectorPathCommandLine(endPoint *Point) *VectorPathCommandLine {
vectorPathCommandLineTemp := VectorPathCommandLine{
tdCommon: tdCommon{Type: "vectorPathCommandLine"},
EndPoint: endPoint,
}
return &vectorPathCommandLineTemp
}
// GetVectorPathCommandEnum return the enum type of this object
func (vectorPathCommandLine *VectorPathCommandLine) GetVectorPathCommandEnum() VectorPathCommandEnum {
return VectorPathCommandLineType
}
// VectorPathCommandCubicBezierCurve A cubic Bézier curve to a given point
type VectorPathCommandCubicBezierCurve struct {
tdCommon
StartControlPoint *Point `json:"start_control_point"` // The start control point of the curve
EndControlPoint *Point `json:"end_control_point"` // The end control point of the curve
EndPoint *Point `json:"end_point"` // The end point of the curve
}
// MessageType return the string telegram-type of VectorPathCommandCubicBezierCurve
func (vectorPathCommandCubicBezierCurve *VectorPathCommandCubicBezierCurve) MessageType() string {
return "vectorPathCommandCubicBezierCurve"
}
// NewVectorPathCommandCubicBezierCurve creates a new VectorPathCommandCubicBezierCurve
//
// @param startControlPoint The start control point of the curve
// @param endControlPoint The end control point of the curve
// @param endPoint The end point of the curve
func NewVectorPathCommandCubicBezierCurve(startControlPoint *Point, endControlPoint *Point, endPoint *Point) *VectorPathCommandCubicBezierCurve {
vectorPathCommandCubicBezierCurveTemp := VectorPathCommandCubicBezierCurve{
tdCommon: tdCommon{Type: "vectorPathCommandCubicBezierCurve"},
StartControlPoint: startControlPoint,
EndControlPoint: endControlPoint,
EndPoint: endPoint,
}
return &vectorPathCommandCubicBezierCurveTemp
}
// GetVectorPathCommandEnum return the enum type of this object
func (vectorPathCommandCubicBezierCurve *VectorPathCommandCubicBezierCurve) GetVectorPathCommandEnum() VectorPathCommandEnum {
return VectorPathCommandCubicBezierCurveType
}