Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CommonLinearGradientBrush.cs « Drawing « Xamarin.PropertyEditing - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6ca792cf68dc4211475233c0355931a72bff6402 (plain)
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
using System;
using System.Collections.Generic;

namespace Xamarin.PropertyEditing.Drawing
{
	/// <summary>
	/// A linear gradient.
	/// </summary>
	[Serializable]
	public class CommonLinearGradientBrush : CommonGradientBrush, IEquatable<CommonLinearGradientBrush>
	{
		public CommonLinearGradientBrush (
			CommonPoint startPoint, CommonPoint endPoint,
			IEnumerable<CommonGradientStop> stops,
			CommonColorInterpolationMode colorInterpolationMode = CommonColorInterpolationMode.SRgbLinearInterpolation,
			CommonBrushMappingMode mappingMode = CommonBrushMappingMode.RelativeToBoundingBox,
			CommonGradientSpreadMethod spreadMethod = CommonGradientSpreadMethod.Pad,
			double opacity = 1.0)
			: base (stops, colorInterpolationMode, mappingMode, spreadMethod, opacity)
		{
			StartPoint = startPoint;
			EndPoint = endPoint;
		}

		/// <summary>
		/// The starting two-dimensional coordinates of the linear gradient.
		/// </summary>
		public CommonPoint StartPoint { get; }
		/// <summary>
		/// The ending two-dimensional coordinates of the linear gradient.
		/// </summary>
		public CommonPoint EndPoint { get; }

		public override bool Equals (object obj)
		{
			var brush = obj as CommonLinearGradientBrush;
			if (brush == null) return false;
			return Equals (brush);
		}

		public bool Equals (CommonLinearGradientBrush other)
		{
			return other != null &&
				   base.Equals (other) &&
				   StartPoint.Equals (other.StartPoint) &&
				   EndPoint.Equals (other.EndPoint);
		}

		public static bool operator == (CommonLinearGradientBrush left, CommonLinearGradientBrush right) => Equals (left, right);
		public static bool operator != (CommonLinearGradientBrush left, CommonLinearGradientBrush right) => !Equals (left, right);

		public override int GetHashCode ()
		{
			var hashCode = base.GetHashCode ();
			unchecked {
				hashCode = hashCode * -1521134295 + StartPoint.GetHashCode ();
				hashCode = hashCode * -1521134295 + EndPoint.GetHashCode ();
			}
			return hashCode;
		}
	}
}