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
e71c9d97
Commit
e71c9d97
authored
Jul 07, 2014
by
Tebjan Halm
Browse files
Merge pull request #80 from bcbarnes-gmx/Devel
Support for 'slice' and fixed '...Max' in aspect ratio
parents
765f8f22
52ccd5c3
Changes
1
Show whitespace changes
Inline
Side-by-side
Source/Document Structure/SvgFragment.cs
View file @
e71c9d97
...
@@ -123,9 +123,17 @@ namespace Svg
...
@@ -123,9 +123,17 @@ namespace Svg
float
fMinY
=
-
this
.
ViewBox
.
MinY
;
float
fMinY
=
-
this
.
ViewBox
.
MinY
;
if
(
AspectRatio
.
Align
!=
SvgPreserveAspectRatio
.
none
)
if
(
AspectRatio
.
Align
!=
SvgPreserveAspectRatio
.
none
)
{
if
(
AspectRatio
.
Slice
)
{
fScaleX
=
Math
.
Max
(
fScaleX
,
fScaleY
);
fScaleY
=
Math
.
Max
(
fScaleX
,
fScaleY
);
}
else
{
{
fScaleX
=
Math
.
Min
(
fScaleX
,
fScaleY
);
fScaleX
=
Math
.
Min
(
fScaleX
,
fScaleY
);
fScaleY
=
Math
.
Min
(
fScaleX
,
fScaleY
);
fScaleY
=
Math
.
Min
(
fScaleX
,
fScaleY
);
}
float
fViewMidX
=
(
this
.
ViewBox
.
Width
/
2
)
*
fScaleX
;
float
fViewMidX
=
(
this
.
ViewBox
.
Width
/
2
)
*
fScaleX
;
float
fViewMidY
=
(
this
.
ViewBox
.
Height
/
2
)
*
fScaleY
;
float
fViewMidY
=
(
this
.
ViewBox
.
Height
/
2
)
*
fScaleY
;
float
fMidX
=
this
.
Width
.
ToDeviceValue
()
/
2
;
float
fMidX
=
this
.
Width
.
ToDeviceValue
()
/
2
;
...
@@ -139,7 +147,7 @@ namespace Svg
...
@@ -139,7 +147,7 @@ namespace Svg
fMinX
+=
(
fMidX
-
fViewMidX
)
/
fScaleX
;
fMinX
+=
(
fMidX
-
fViewMidX
)
/
fScaleX
;
break
;
break
;
case
SvgPreserveAspectRatio
.
xMaxYMin
:
case
SvgPreserveAspectRatio
.
xMaxYMin
:
fMinX
+=
this
.
ViewBox
.
Width
-
this
.
Width
.
ToDeviceValue
();
fMinX
+=
(
this
.
Width
.
ToDeviceValue
()
/
fScaleX
)
-
this
.
ViewBox
.
Width
;
break
;
break
;
case
SvgPreserveAspectRatio
.
xMinYMid
:
case
SvgPreserveAspectRatio
.
xMinYMid
:
fMinY
+=
(
fMidY
-
fViewMidY
)
/
fScaleY
;
fMinY
+=
(
fMidY
-
fViewMidY
)
/
fScaleY
;
...
@@ -149,28 +157,28 @@ namespace Svg
...
@@ -149,28 +157,28 @@ namespace Svg
fMinY
+=
(
fMidY
-
fViewMidY
)
/
fScaleY
;
fMinY
+=
(
fMidY
-
fViewMidY
)
/
fScaleY
;
break
;
break
;
case
SvgPreserveAspectRatio
.
xMaxYMid
:
case
SvgPreserveAspectRatio
.
xMaxYMid
:
fMinX
+=
this
.
ViewBox
.
Width
-
this
.
Width
.
ToDeviceValue
();
fMinX
+=
(
this
.
Width
.
ToDeviceValue
()
/
fScaleX
)
-
this
.
ViewBox
.
Width
;
fMinY
+=
(
fMidY
-
fViewMidY
)
/
fScaleY
;
fMinY
+=
(
fMidY
-
fViewMidY
)
/
fScaleY
;
break
;
break
;
case
SvgPreserveAspectRatio
.
xMinYMax
:
case
SvgPreserveAspectRatio
.
xMinYMax
:
fMinY
+=
this
.
ViewBox
.
Height
-
this
.
Height
.
ToDeviceValue
();
fMinY
+=
(
this
.
Height
.
ToDeviceValue
()
/
fScaleY
)
-
this
.
ViewBox
.
Height
;
break
;
break
;
case
SvgPreserveAspectRatio
.
xMidYMax
:
case
SvgPreserveAspectRatio
.
xMidYMax
:
fMinX
+=
(
fMidX
-
fViewMidX
)
/
fScaleX
;
fMinX
+=
(
fMidX
-
fViewMidX
)
/
fScaleX
;
fMinY
+=
this
.
ViewBox
.
Height
-
this
.
Height
.
ToDeviceValue
();
fMinY
+=
(
this
.
Height
.
ToDeviceValue
()
/
fScaleY
)
-
this
.
ViewBox
.
Height
;
break
;
break
;
case
SvgPreserveAspectRatio
.
xMaxYMax
:
case
SvgPreserveAspectRatio
.
xMaxYMax
:
fMinX
+=
this
.
ViewBox
.
Width
-
this
.
Width
.
ToDeviceValue
();
fMinX
+=
(
this
.
Width
.
ToDeviceValue
()
/
fScaleX
)
-
this
.
ViewBox
.
Width
;
fMinY
+=
this
.
ViewBox
.
Height
-
this
.
Height
.
ToDeviceValue
();
fMinY
+=
(
this
.
Height
.
ToDeviceValue
()
/
fScaleY
)
-
this
.
ViewBox
.
Height
;
break
;
break
;
default
:
default
:
break
;
break
;
}
}
}
}
renderer
.
TranslateTransform
(
_x
,
_y
,
MatrixOrder
.
Append
);
renderer
.
TranslateTransform
(
_x
,
_y
);
renderer
.
TranslateTransform
(
fMinX
,
fMinY
,
MatrixOrder
.
Append
);
renderer
.
TranslateTransform
(
fMinX
,
fMinY
);
renderer
.
ScaleTransform
(
fScaleX
,
fScaleY
,
MatrixOrder
.
Append
);
renderer
.
ScaleTransform
(
fScaleX
,
fScaleY
);
}
}
}
}
...
...
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