-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEllipseElement.cs
More file actions
65 lines (51 loc) · 1.69 KB
/
EllipseElement.cs
File metadata and controls
65 lines (51 loc) · 1.69 KB
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
#region copyright LGPL nanoLogika
// Copyright 2023, nanoLogika GmbH.
// All rights reserved.
// This source code is licensed under the "LGPL v3 or any later version" license.
// See LICENSE file in the project root for full license information.
#endregion
using System.Xml.Linq;
namespace SvgElements {
/// <summary>
/// Represents SVG <i>ellipse</i> element.
/// </summary>
public class EllipseElement : SvgElementBase<EllipseElement> {
/// <summary>
/// Gets or sets the x-coordinate of the ellipse center.
/// </summary>
public double Cx { get; set; }
/// <summary>
/// Gets or sets the y-coordinate of the ellipse center.
/// </summary>
public double Cy { get; set; }
/// <summary>
/// Gets or sets the ellipse axis in x-direction.
/// This property must be specified.
/// </summary>
public double Rx { get; set; }
/// <summary>
/// Gets or sets the ellipse axis in y-direction.
/// This property must be specified.
/// </summary>
public double Ry { get; set; }
/// <inheritdoc />
public override XElement GetXml() {
if (Rx == 0 || Ry == 0) {
throw new InvalidOperationException("EllipseElement.Rx, .Ry must be specified.");
}
XElement xElement = new XElement("ellipse");
AddID(xElement);
AddClass(xElement);
AddTransform(xElement);
xElement.Add(new XAttribute("cx", Cd(Cx)));
xElement.Add(new XAttribute("cy", Cd(Cy)));
xElement.Add(new XAttribute("rx", Cd(Rx)));
xElement.Add(new XAttribute("ry", Cd(Ry)));
AddStroke(xElement);
AddStrokeDashArray(xElement);
AddFill(xElement);
xElement.Value = string.Empty;
return xElement;
}
}
}