Class SvgCoordinateUtils
public class SvgCoordinateUtils
- Inheritance
-
SvgCoordinateUtils
- Inherited Members
Constructors
SvgCoordinateUtils()
public SvgCoordinateUtils()
Methods
ApplyViewBox(Rectangle, Rectangle, string, string)
Returns the viewBox received after scaling and displacement given preserveAspectRatio.
public static Rectangle ApplyViewBox(Rectangle viewBox, Rectangle currentViewPort, string align, string meetOrSlice)
Parameters
viewBox
Rectangleparsed viewBox rectangle. It should be a valid Rectangle
currentViewPort
Rectanglecurrent element view port. It should be a valid Rectangle
align
stringthe alignment value that indicates whether to force uniform scaling and, if so, the alignment method to use in case the aspect ratio of the viewBox doesn't match the aspect ratio of the viewport. If align is null or align is invalid (i.e. not in the predefined list), then the default logic with align = "xMidYMid", and meetOrSlice = "meet" would be used
meetOrSlice
stringthe way to scale the viewBox. If meetOrSlice is not null and invalid, then the default logic with align = "xMidYMid" and meetOrSlice = "meet" would be used, if meetOrSlice is null then default "meet" value would be used with the specified align
Returns
CalculateAngleBetweenTwoVectors(Vector, Vector)
Calculate the angle between two vectors
public static double CalculateAngleBetweenTwoVectors(Vector vectorA, Vector vectorB)
Parameters
Returns
- double
angle between vectors in radians units
GetCoordinateForObjectBoundingBox(string, double)
Returns a value relative to the object bounding box.
public static double GetCoordinateForObjectBoundingBox(string attributeValue, double defaultValue)
Parameters
attributeValue
stringattribute value to parse
defaultValue
doublethis value will be returned if an error occurs while parsing the attribute value
Returns
- double
if
attributeValue
is a percentage value, the given percentage of 1 will be returned. And if it's a valid value with a number, the number will be extracted from that value.
Remarks
Returns a value relative to the object bounding box. We should only call this method for attributes with coordinates relative to the object bounding rectangle.
GetCoordinateForUserSpaceOnUse(string, double, double, double, float, float)
Returns absolute value for attribute in userSpaceOnUse coordinate system.
public static double GetCoordinateForUserSpaceOnUse(string attributeValue, double defaultValue, double start, double length, float em, float rem)
Parameters
attributeValue
stringvalue of attribute.
defaultValue
doubledefault value.
start
doublestart border for calculating percent value.
length
doublelength for calculating percent value.
em
floatem value.
rem
floatrem value.
Returns
- double
absolute value in the userSpaceOnUse coordinate system.
MakeRelativeOperatorCoordinatesAbsolute(string[], double[])
Converts relative coordinates to absolute ones.
public static string[] MakeRelativeOperatorCoordinatesAbsolute(string[] relativeCoordinates, double[] currentCoordinates)
Parameters
relativeCoordinates
string[]the initial set of coordinates
currentCoordinates
double[]an array representing the point relative to which the relativeCoordinates are defined
Returns
- string[]
a String array of absolute coordinates, with the same length as the input array
Remarks
Converts relative coordinates to absolute ones. Assumes that relative coordinates are represented by an array of coordinates with length proportional to the length of current coordinates array, so that current coordinates array is applied in segments to the relative coordinates array