Table of Contents

Class SvgCoordinateUtils

Namespace
iText.Svg.Utils
Assembly
itext.svg.dll
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 Rectangle

parsed viewBox rectangle. It should be a valid Rectangle

currentViewPort Rectangle

current element view port. It should be a valid Rectangle

align string

the 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 string

the 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

Rectangle

the applied viewBox Rectangle

CalculateAngleBetweenTwoVectors(Vector, Vector)

Calculate the angle between two vectors

public static double CalculateAngleBetweenTwoVectors(Vector vectorA, Vector vectorB)

Parameters

vectorA Vector

first vector

vectorB Vector

second vector

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 string

attribute value to parse

defaultValue double

this 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 string

value of attribute.

defaultValue double

default value.

start double

start border for calculating percent value.

length double

length for calculating percent value.

em float

em value.

rem float

rem 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