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
4f3df864
Commit
4f3df864
authored
Jul 03, 2014
by
Brian C. Barnes
Committed by
Eric Domke
Jul 24, 2014
Browse files
Support for 'slice' and fixed '...Max' in aspect ratio
parent
9521956d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Source/Document Structure/SvgFragment.cs
View file @
4f3df864
...
...
@@ -124,8 +124,16 @@ namespace Svg
if
(
AspectRatio
.
Align
!=
SvgPreserveAspectRatio
.
none
)
{
fScaleX
=
Math
.
Min
(
fScaleX
,
fScaleY
);
fScaleY
=
Math
.
Min
(
fScaleX
,
fScaleY
);
if
(
AspectRatio
.
Slice
)
{
fScaleX
=
Math
.
Max
(
fScaleX
,
fScaleY
);
fScaleY
=
Math
.
Max
(
fScaleX
,
fScaleY
);
}
else
{
fScaleX
=
Math
.
Min
(
fScaleX
,
fScaleY
);
fScaleY
=
Math
.
Min
(
fScaleX
,
fScaleY
);
}
float
fViewMidX
=
(
this
.
ViewBox
.
Width
/
2
)
*
fScaleX
;
float
fViewMidY
=
(
this
.
ViewBox
.
Height
/
2
)
*
fScaleY
;
float
fMidX
=
this
.
Width
.
ToDeviceValue
()
/
2
;
...
...
@@ -139,7 +147,7 @@ namespace Svg
fMinX
+=
(
fMidX
-
fViewMidX
)
/
fScaleX
;
break
;
case
SvgPreserveAspectRatio
.
xMaxYMin
:
fMinX
+=
this
.
ViewBox
.
Width
-
this
.
Width
.
ToDeviceValue
();
fMinX
+=
(
this
.
Width
.
ToDeviceValue
()
/
fScaleX
)
-
this
.
ViewBox
.
Width
;
break
;
case
SvgPreserveAspectRatio
.
xMinYMid
:
fMinY
+=
(
fMidY
-
fViewMidY
)
/
fScaleY
;
...
...
@@ -149,28 +157,28 @@ namespace Svg
fMinY
+=
(
fMidY
-
fViewMidY
)
/
fScaleY
;
break
;
case
SvgPreserveAspectRatio
.
xMaxYMid
:
fMinX
+=
this
.
ViewBox
.
Width
-
this
.
Width
.
ToDeviceValue
();
fMinX
+=
(
this
.
Width
.
ToDeviceValue
()
/
fScaleX
)
-
this
.
ViewBox
.
Width
;
fMinY
+=
(
fMidY
-
fViewMidY
)
/
fScaleY
;
break
;
case
SvgPreserveAspectRatio
.
xMinYMax
:
fMinY
+=
this
.
ViewBox
.
Height
-
this
.
Height
.
ToDeviceValue
();
fMinY
+=
(
this
.
Height
.
ToDeviceValue
()
/
fScaleY
)
-
this
.
ViewBox
.
Height
;
break
;
case
SvgPreserveAspectRatio
.
xMidYMax
:
fMinX
+=
(
fMidX
-
fViewMidX
)
/
fScaleX
;
fMinY
+=
this
.
ViewBox
.
Height
-
this
.
Height
.
ToDeviceValue
();
fMinY
+=
(
this
.
Height
.
ToDeviceValue
()
/
fScaleY
)
-
this
.
ViewBox
.
Height
;
break
;
case
SvgPreserveAspectRatio
.
xMaxYMax
:
fMinX
+=
this
.
ViewBox
.
Width
-
this
.
Width
.
ToDeviceValue
();
fMinY
+=
this
.
ViewBox
.
Height
-
this
.
Height
.
ToDeviceValue
();
fMinX
+=
(
this
.
Width
.
ToDeviceValue
()
/
fScaleX
)
-
this
.
ViewBox
.
Width
;
fMinY
+=
(
this
.
Height
.
ToDeviceValue
()
/
fScaleY
)
-
this
.
ViewBox
.
Height
;
break
;
default
:
break
;
}
}
renderer
.
TranslateTransform
(
_x
,
_y
,
MatrixOrder
.
Append
);
renderer
.
TranslateTransform
(
fMinX
,
fMinY
,
MatrixOrder
.
Append
);
renderer
.
ScaleTransform
(
fScaleX
,
fScaleY
,
MatrixOrder
.
Append
);
renderer
.
TranslateTransform
(
_x
,
_y
);
renderer
.
TranslateTransform
(
fMinX
,
fMinY
);
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