Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ImportedProjects
SVG
Commits
027bfcc9
Commit
027bfcc9
authored
Jan 25, 2019
by
Vadim
Committed by
mrbean-bremen
Jan 24, 2019
Browse files
Repair calculating a percentage value (#410)
* Repair calculate a percentage value * Add percentage size tests
parent
4d4acd6e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Source/Basic Shapes/SvgEllipse.cs
View file @
027bfcc9
...
...
@@ -93,11 +93,12 @@ namespace Svg
}
var
center
=
SvgUnit
.
GetDevicePoint
(
this
.
_centerX
,
this
.
_centerY
,
renderer
,
this
);
var
radius
=
SvgUnit
.
GetDevicePoint
(
this
.
_radiusX
+
halfStrokeWidth
,
this
.
_radiusY
+
halfStrokeWidth
,
renderer
,
this
);
var
radiusX
=
this
.
RadiusX
.
ToDeviceValue
(
renderer
,
UnitRenderingType
.
Other
,
this
)
+
halfStrokeWidth
;
var
radiusY
=
this
.
RadiusY
.
ToDeviceValue
(
renderer
,
UnitRenderingType
.
Other
,
this
)
+
halfStrokeWidth
;
this
.
_path
=
new
GraphicsPath
();
_path
.
StartFigure
();
_path
.
AddEllipse
(
center
.
X
-
radius
.
X
,
center
.
Y
-
radius
.
Y
,
2
*
radius
.
X
,
2
*
radius
.
Y
);
_path
.
AddEllipse
(
center
.
X
-
radiusX
,
center
.
Y
-
radiusY
,
2
*
radiusX
,
2
*
radiusY
);
_path
.
CloseFigure
();
}
return
_path
;
...
...
Tests/Svg.UnitTests/PercentageSizeTests.cs
0 → 100644
View file @
027bfcc9
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
namespace
Svg.UnitTests
{
[
TestClass
]
public
class
PercentageSizeTests
{
[
TestMethod
]
public
void
TestRectangle
()
{
var
svgRectangle
=
new
SvgRectangle
()
{
X
=
new
SvgUnit
(
SvgUnitType
.
Percentage
,
50
),
Y
=
new
SvgUnit
(
SvgUnitType
.
Percentage
,
50
),
Width
=
new
SvgUnit
(
SvgUnitType
.
Percentage
,
15
),
Height
=
new
SvgUnit
(
SvgUnitType
.
Percentage
,
20
)
};
CheckPercentageSize
(
svgRectangle
);
}
[
TestMethod
]
public
void
TestCircle
()
{
var
svgCircle
=
new
SvgCircle
()
{
CenterX
=
new
SvgUnit
(
SvgUnitType
.
Percentage
,
50
),
CenterY
=
new
SvgUnit
(
SvgUnitType
.
Percentage
,
50
),
Radius
=
new
SvgUnit
(
SvgUnitType
.
Percentage
,
15
),
};
CheckPercentageSize
(
svgCircle
);
}
[
TestMethod
]
public
void
TestEllipse
()
{
var
svgEllipse
=
new
SvgEllipse
()
{
CenterX
=
new
SvgUnit
(
SvgUnitType
.
Percentage
,
50
),
CenterY
=
new
SvgUnit
(
SvgUnitType
.
Percentage
,
50
),
RadiusX
=
new
SvgUnit
(
SvgUnitType
.
Percentage
,
15
),
RadiusY
=
new
SvgUnit
(
SvgUnitType
.
Percentage
,
5
),
};
CheckPercentageSize
(
svgEllipse
);
}
private
void
CheckPercentageSize
(
SvgVisualElement
element
)
{
var
svgDoc
=
new
SvgDocument
()
{
Width
=
200
,
Height
=
200
};
svgDoc
.
Children
.
Add
(
element
);
var
boudsPref
=
element
.
Bounds
;
svgDoc
.
Width
=
400
;
svgDoc
.
Height
=
400
;
var
boundsAfter
=
element
.
Bounds
;
Assert
.
AreNotEqual
(
boudsPref
.
Size
,
boundsAfter
.
Size
,
"To device value convert error"
);
}
}
}
Tests/Svg.UnitTests/Svg.UnitTests.csproj
View file @
027bfcc9
...
...
@@ -69,6 +69,7 @@
<Compile
Include=
"SvgTextTests.cs"
/>
<Compile
Include=
"SvgTextElementDeepCopyTest.cs"
/>
<Compile
Include=
"ImageComparisonTest.cs"
/>
<Compile
Include=
"PercentageSizeTests.cs"
/>
</ItemGroup>
<ItemGroup>
<ProjectReference
Include=
"..\..\Source\Svg.csproj"
>
...
...
@@ -107,11 +108,11 @@
<EmbeddedResource
Include=
"Resources\Issue_Threading\TestFile.svg"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildBinPath)\Microsoft.CSharp.targets"
/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment