• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 16520510906

25 Jul 2025 11:07AM UTC coverage: 75.22% (+0.04%) from 75.178%
16520510906

push

github

web-flow
Merge pull request #721 from DomCR/svg-units

SVG paper units

6062 of 8858 branches covered (68.44%)

Branch coverage included in aggregate %.

98 of 113 new or added lines in 6 files covered. (86.73%)

5 existing lines in 1 file now uncovered.

24023 of 31138 relevant lines covered (77.15%)

78683.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

46.34
/src/ACadSharp/IO/SVG/SvgConfiguration.cs
1
using ACadSharp.Objects;
2
using ACadSharp.Types.Units;
3
using CSMath;
4
using System;
5
using System.ComponentModel;
6

7
namespace ACadSharp.IO
8
{
9
        /// <summary>
10
        /// Configuration for writing SVG files.
11
        /// </summary>
12
        public class SvgConfiguration : CadWriterConfiguration
13
        {
14
                /// <summary>
15
                /// The <see cref="LineweightType"/> will be divided by this value to process the stroke-width in the svg when the units are <see cref="UnitsType.Unitless"/>.
16
                /// </summary>
17
                /// <remarks>
18
                /// The default value is 100, which matches with the line weight real value in mm.
19
                /// </remarks>
20
                public double LineWeightRatio { get; set; } = 100;
1,151✔
21

22
                /// <summary>
23
                /// Weight value for the <see cref="LineweightType.Default"/>. 
24
                /// </summary>
25
                /// <value>
26
                /// Value must be in mm.
27
                /// </value>
28
                public double DefaultLineWeight { get; set; } = 0.01;
1,194✔
29

30
                /// <summary>
31
                /// Radius applied for the points.
32
                /// </summary>
33
                /// <remarks>
34
                /// In svg the points will be drawn as circles.
35
                /// </remarks>
36
                public double PointRadius { get; set; } = 0.1;
574✔
37

38
                /// <summary>
39
                /// Get the value of the stroke-width in mm.
40
                /// </summary>
41
                /// <param name="lineweightType"></param>
42
                /// <param name="units"></param>
43
                /// <returns></returns>
44
                public double GetLineWeightValue(LineweightType lineweightType, UnitsType units)
45
                {
92✔
46
                        double value = Math.Abs((double)lineweightType);
92✔
47

48
                        if (units == UnitsType.Unitless)
92✔
49
                        {
17✔
50
                                return value / this.LineWeightRatio;
17✔
51
                        }
52

53
                        switch (lineweightType)
75✔
54
                        {
55
                                case LineweightType.Default:
56
                                        return this.DefaultLineWeight;
60✔
57
                                case LineweightType.W0:
58
                                        return 0.001;
1✔
59
                        }
60

61
                        return value / 100;
14✔
62
                }
92✔
63

64
                public static double ToPixelSize(double value, PlotPaperUnits units)
UNCOV
65
                {
×
UNCOV
66
                        switch (units)
×
67
                        {
68
                                case PlotPaperUnits.Inches:
UNCOV
69
                                        return value * 96;
×
70
                                case PlotPaperUnits.Millimeters:
UNCOV
71
                                        return value * 96 / 25.4;
×
72
                                case PlotPaperUnits.Pixels:
73
                                        return value;
×
74
                                default:
75
                                        throw new InvalidEnumArgumentException(nameof(units), (int)units, typeof(PlotPaperUnits));
×
76
                        }
UNCOV
77
                }
×
78

79
                public static T ToPixelSize<T>(T value, PlotPaperUnits units)
80
                        where T : IVector
NEW
81
                {
×
NEW
82
                        for (int i = 0; i < value.Dimension; i++)
×
NEW
83
                        {
×
NEW
84
                                value[i] = ToPixelSize(value[i], units);
×
NEW
85
                        }
×
86

NEW
87
                        return value;
×
NEW
88
                }
×
89
        }
90
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc