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
2a4bc179
Commit
2a4bc179
authored
Mar 12, 2017
by
Tebjan Halm
Committed by
GitHub
Mar 12, 2017
Browse files
Merge pull request #293 from mrbean-bremen/svg-bounds
Correctly handle embedded SVG fragments without viewbox
parents
f9181931
52b7d326
Changes
4
Hide whitespace changes
Inline
Side-by-side
Source/Document Structure/SvgFragment.cs
View file @
2a4bc179
...
...
@@ -211,7 +211,34 @@ namespace Svg
{
get
{
return
this
.
Path
.
GetBounds
();
var
bounds
=
new
RectangleF
();
foreach
(
var
child
in
this
.
Children
)
{
RectangleF
childBounds
=
new
RectangleF
();
if
(
child
is
SvgFragment
)
{
childBounds
=
((
SvgFragment
)
child
).
Bounds
;
childBounds
.
Offset
(((
SvgFragment
)
child
).
X
,
((
SvgFragment
)
child
).
Y
);
}
else
if
(
child
is
SvgVisualElement
)
{
childBounds
=
((
SvgVisualElement
)
child
).
Bounds
;
}
if
(!
childBounds
.
IsEmpty
)
{
if
(
bounds
.
IsEmpty
)
{
bounds
=
childBounds
;
}
else
{
bounds
=
RectangleF
.
Union
(
bounds
,
childBounds
);
}
}
}
return
bounds
;
}
}
...
...
@@ -244,13 +271,12 @@ namespace Svg
else
{
bounds
=
this
.
Bounds
;
//do just one call to the recursive bounds property
this
.
ViewBox
=
new
SvgViewBox
(
bounds
.
X
,
bounds
.
Y
,
bounds
.
Width
,
bounds
.
Height
);
}
}
if
(
isWidthperc
)
{
w
=
(
bounds
.
Width
)
*
(
Width
.
Value
*
0.01f
);
w
=
(
bounds
.
Width
+
bounds
.
X
)
*
(
Width
.
Value
*
0.01f
);
}
else
{
...
...
@@ -258,7 +284,7 @@ namespace Svg
}
if
(
isHeightperc
)
{
h
=
(
bounds
.
Height
)
*
(
Height
.
Value
*
0.01f
);
h
=
(
bounds
.
Height
+
bounds
.
Y
)
*
(
Height
.
Value
*
0.01f
);
}
else
{
...
...
Tests/W3CTestSuite/png/__issue-244-01.png
0 → 100644
View file @
2a4bc179
1.32 KB
Tests/W3CTestSuite/png/__issue-279-01.png
View replaced file @
f9181931
View file @
2a4bc179
10.8 KB
|
W:
|
H:
9.38 KB
|
W:
|
H:
2-up
Swipe
Onion skin
Tests/W3CTestSuite/svg/__issue-244-01.svg
0 → 100644
View file @
2a4bc179
<svg
xmlns=
"http://www.w3.org/2000/svg"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
>
<svg
id=
"svg1"
x=
"30"
viewBox=
"0 0 100 100"
>
<rect
id=
"rect1"
x=
"10"
y=
"10"
height=
"100"
width=
"100"
style=
"stroke:#ff0000; fill: #0000ff"
/>
</svg>
<svg
id=
"svg1"
x=
"200"
y=
"20"
viewBox=
"0 0 100 100"
>
<rect
id=
"rect2"
x=
"10"
y=
"10"
height=
"100"
width=
"100"
style=
"stroke:#009900; fill: #00cc00"
/>
</svg>
</svg>
\ 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