22 internal class RenderingParameters : IEquatable<RenderingParameters>
24 public static float Tolerance = 1e-5f;
25 public float Left {
get; }
26 public float Top {
get; }
27 public float Width {
get; }
28 public float Height {
get; }
29 public float Scale {
get; }
30 public int RenderWidth {
get; }
31 public int RenderHeight {
get; }
33 public RenderingParameters(
float left,
float top,
float width,
float height,
float scale,
int renderWidth,
int renderHeight)
40 this.RenderWidth = renderWidth;
41 this.RenderHeight = renderHeight;
44 public RenderingParameters Clone()
46 return new RenderingParameters(this.Left, this.Top, this.Width, this.Height, this.Scale, this.RenderWidth, this.RenderHeight);
49 public bool Equals(RenderingParameters other)
51 if (!
object.ReferenceEquals(other,
null))
53 return this.Scale == other.Scale && this.
Left == other.Left && this.
Top == other.Top && this.Width == other.Width && this.Height == other.Height && this.RenderWidth == other.RenderWidth && this.RenderHeight == other.RenderHeight;
61 public override bool Equals(
object obj)
63 if (obj is RenderingParameters other)
65 return this.Equals(other);
73 public override int GetHashCode()
79 hash = (hash * 7) + this.
Left.GetHashCode();
80 hash = (hash * 7) + this.
Top.GetHashCode();
81 hash = (hash * 7) + this.Width.GetHashCode();
82 hash = (hash * 7) + this.Height.GetHashCode();
83 hash = (hash * 7) + this.Scale.GetHashCode();
84 hash = (hash * 7) + this.RenderWidth.GetHashCode();
85 hash = (hash * 7) + this.RenderHeight.GetHashCode();
91 public static bool operator ==(RenderingParameters param1, RenderingParameters param2)
93 if (
object.ReferenceEquals(param1,
null))
95 return object.ReferenceEquals(param2,
null);
99 return param1.Equals(param2);
103 public static bool operator !=(RenderingParameters param1, RenderingParameters param2)
105 if (!
object.ReferenceEquals(param1,
null) && !
object.ReferenceEquals(param2,
null))
107 return param1.Scale != param2.Scale || param1.Left != param2.Left || param1.Top != param2.Top || param1.Width != param2.Width || param1.Height != param2.Height || param1.RenderWidth != param2.RenderWidth || param1.RenderHeight != param2.RenderHeight;
111 return !(
object.ReferenceEquals(param1,
null) &&
object.ReferenceEquals(param2,
null));
115 public bool GoodEnough(RenderingParameters other)
117 if (this.Scale == other.Scale)
119 return (this.Left <= other.Left && (
this.Left +
this.Width - other.Left - other.Width) / (
this.Left +
this.Width + other.Left + other.Width) >= -Tolerance &&
this.Top <= other.Top && (
this.Top +
this.Height - other.Top - other.Height) / (
this.Top +
this.Height + other.Top + other.Height) >= -Tolerance);