Rebracer update.
1 // --------------------------------------------------------------------------------------------------------------------
2 // <copyright file="OxyPen.cs" company="OxyPlot">
3 // The MIT License (MIT)
5 // Copyright (c) 2012 Oystein Bjorke
7 // Permission is hereby granted, free of charge, to any person obtaining a
8 // copy of this software and associated documentation files (the
9 // "Software"), to deal in the Software without restriction, including
10 // without limitation the rights to use, copy, modify, merge, publish,
11 // distribute, sublicense, and/or sell copies of the Software, and to
12 // permit persons to whom the Software is furnished to do so, subject to
13 // the following conditions:
15 // The above copyright notice and this permission notice shall be included
16 // in all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 // Describes a pen in terms of color, thickness, line style and line join type.
29 // --------------------------------------------------------------------------------------------------------------------
35 /// Describes a pen in terms of color, thickness, line style and line join type.
40 /// Initializes a new instance of the <see cref="OxyPen"/> class.
42 /// <param name="color">
45 /// <param name="thickness">
48 /// <param name="lineStyle">
51 /// <param name="lineJoin">
56 double thickness = 1.0,
57 LineStyle lineStyle = LineStyle.Solid,
58 OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter)
61 this.Thickness = thickness;
62 this.DashArray = LineStyleHelper.GetDashArray(lineStyle);
63 this.LineStyle = lineStyle;
64 this.LineJoin = lineJoin;
68 /// Gets or sets the color.
70 /// <value>The color.</value>
71 public OxyColor Color { get; set; }
74 /// Gets or sets the dash array.
76 /// <value>The dash array.</value>
77 public double[] DashArray { get; set; }
80 /// Gets or sets the line join.
82 /// <value>The line join.</value>
83 public OxyPenLineJoin LineJoin { get; set; }
86 /// Gets or sets the line style.
88 /// <value>The line style.</value>
89 public LineStyle LineStyle { get; set; }
92 /// Gets or sets the thickness.
94 /// <value>The thickness.</value>
95 public double Thickness { get; set; }
98 /// Creates the specified pen.
100 /// <param name="color">The color.</param>
101 /// <param name="thickness">The thickness.</param>
102 /// <param name="lineStyle">The line style.</param>
103 /// <param name="lineJoin">The line join.</param>
104 /// <returns>A pen.</returns>
105 public static OxyPen Create(
108 LineStyle lineStyle = LineStyle.Solid,
109 OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter)
111 if (color == null || lineStyle == LineStyle.None || Math.Abs(thickness) < double.Epsilon)
116 return new OxyPen(color, thickness, lineStyle, lineJoin);
120 /// Returns a hash code for this instance.
123 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
125 public override int GetHashCode()
129 int result = this.Color.GetHashCode();
130 result = (result * 397) ^ this.Thickness.GetHashCode();
131 result = (result * 397) ^ this.LineStyle.GetHashCode();
132 result = (result * 397) ^ this.LineJoin.GetHashCode();