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
0b727f1b
Commit
0b727f1b
authored
Mar 02, 2017
by
Tebjan Halm
Committed by
GitHub
Mar 02, 2017
Browse files
Merge pull request #285 from LightningDragon/master
Added array caching to AddToPath for a significant performance increase.
parents
df31b65d
f1a927c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Source/Paths/SvgClosePathSegment.cs
View file @
0b727f1b
...
...
@@ -9,13 +9,17 @@ namespace Svg.Pathing
public
override
void
AddToPath
(
System
.
Drawing
.
Drawing2D
.
GraphicsPath
graphicsPath
)
{
// Important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure.
if
(
graphicsPath
.
PointCount
>
0
&&
!
graphicsPath
.
PathPoints
[
0
].
Equals
(
graphicsPath
.
PathPoints
[
graphicsPath
.
PathPoints
.
Length
-
1
]))
var
pathPoints
=
graphicsPath
.
PathPoints
;
if
(
pathPoints
.
Length
>
0
&&
!
pathPoints
[
0
].
Equals
(
pathPoints
[
pathPoints
.
Length
-
1
]))
{
int
i
=
graphicsPath
.
PathTypes
.
Length
-
1
;
while
(
i
>=
0
&&
graphicsPath
.
PathTypes
[
i
]
>
0
)
i
--;
var
pathTypes
=
graphicsPath
.
PathTypes
;
int
i
=
pathPoints
.
Length
-
1
;
while
(
i
>=
0
&&
pathTypes
[
i
]
>
0
)
i
--;
if
(
i
<
0
)
i
=
0
;
graphicsPath
.
AddLine
(
graphicsPath
.
PathPoints
[
graphicsPath
.
P
athPoints
.
Length
-
1
],
graphicsPath
.
P
athPoints
[
i
]);
graphicsPath
.
AddLine
(
pathPoints
[
p
athPoints
.
Length
-
1
],
p
athPoints
[
i
]);
}
graphicsPath
.
CloseFigure
();
}
...
...
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