/
BoundingBox.cs
99 lines (88 loc) · 3.07 KB
/
BoundingBox.cs
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
using System;
using PuppeteerSharp.Media;
namespace PuppeteerSharp
{
/// <summary>
/// Bounding box data returned by <see cref="IElementHandle.BoundingBoxAsync"/>.
/// </summary>
public class BoundingBox : IEquatable<BoundingBox>
{
/// <summary>
/// Initializes a new instance of the <see cref="BoundingBox"/> class.
/// </summary>
public BoundingBox()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BoundingBox"/> class.
/// </summary>
/// <param name="x">The x coordinate.</param>
/// <param name="y">The y coordinate.</param>
/// <param name="width">Width.</param>
/// <param name="height">Height.</param>
public BoundingBox(decimal x, decimal y, decimal width, decimal height)
{
X = x;
Y = y;
Width = width;
Height = height;
}
/// <summary>
/// The x coordinate of the element in pixels.
/// </summary>
/// <value>The x.</value>
public decimal X { get; set; }
/// <summary>
/// The y coordinate of the element in pixels.
/// </summary>
/// <value>The y.</value>
public decimal Y { get; set; }
/// <summary>
/// The width of the element in pixels.
/// </summary>
/// <value>The width.</value>
public decimal Width { get; set; }
/// <summary>
/// The height of the element in pixels.
/// </summary>
/// <value>The height.</value>
public decimal Height { get; set; }
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
return Equals((BoundingBox)obj);
}
/// <summary>
/// Determines whether the specified <see cref="PuppeteerSharp.BoundingBox"/> is equal to the current <see cref="T:PuppeteerSharp.BoundingBox"/>.
/// </summary>
/// <param name="obj">The <see cref="PuppeteerSharp.BoundingBox"/> to compare with the current <see cref="T:PuppeteerSharp.BoundingBox"/>.</param>
/// <returns><c>true</c> if the specified <see cref="PuppeteerSharp.BoundingBox"/> is equal to the current
/// <see cref="T:PuppeteerSharp.BoundingBox"/>; otherwise, <c>false</c>.</returns>
public bool Equals(BoundingBox obj)
=> obj != null &&
obj.X == X &&
obj.Y == Y &&
obj.Height == Height &&
obj.Width == Width;
/// <inheritdoc/>
public override int GetHashCode()
=> X.GetHashCode() * 397
^ Y.GetHashCode() * 397
^ Width.GetHashCode() * 397
^ Height.GetHashCode() * 397;
internal Clip ToClip()
{
return new Clip
{
X = X,
Y = Y,
Width = Width,
Height = Height,
};
}
}
}