Skip to main content

canvg

Classes

Interfaces

Namespaces

Type aliases

CreateCanvas

Ƭ CreateCanvas: (width: number, height: number) => HTMLCanvasElement | OffscreenCanvas

Type declaration

▸ (width, height): HTMLCanvasElement | OffscreenCanvas

Function to create new canvas.

Parameters
NameType
widthnumber
heightnumber
Returns

HTMLCanvasElement | OffscreenCanvas

Defined in

src/Document/Document.ts:19


CreateImage

Ƭ CreateImage: (src: string, anonymousCrossOrigin?: boolean) => Promise<CanvasImageSource>

Type declaration

▸ (src, anonymousCrossOrigin?): Promise<CanvasImageSource>

Function to create new image.

Parameters
NameType
srcstring
anonymousCrossOrigin?boolean
Returns

Promise<CanvasImageSource>

Defined in

src/Document/Document.ts:24


IViewBoxConfig

Ƭ IViewBoxConfig: Omit<IScreenViewBoxConfig, "document">

Defined in

src/Document/Document.ts:49


AnyElement

Ƭ AnyElement: Elements[keyof Elements]

Defined in

src/Document/elements.ts:93


CommandType

Ƭ CommandType: SVGCommand["type"]

Defined in

src/PathParser.ts:17


Command

Ƭ Command: { type: CommandType } & Omit<CommandM, "type"> & Omit<CommandL, "type"> & Omit<CommandH, "type"> & Omit<CommandV, "type"> & Omit<CommandZ, "type"> & Omit<CommandQ, "type"> & Omit<CommandT, "type"> & Omit<CommandC, "type"> & Omit<CommandS, "type"> & Omit<CommandA, "type">

Defined in

src/PathParser.ts:18


Axis

Ƭ Axis: "x" | "y"

Defined in

src/ViewPort.ts:7


MatrixValue

Ƭ MatrixValue: readonly [number, number, number, number, number, number]

Defined in

src/types.ts:1


VectorValue

Ƭ VectorValue: readonly [number, number]

Defined in

src/types.ts:3


RenderingContext2D

Ƭ RenderingContext2D: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D

Defined in

src/types.ts:5


Fetch

Ƭ Fetch: typeof __type

Defined in

src/types.ts:7

Variables

elements

Const elements: Object

Type declaration

NameType
svgtypeof SVGElement
recttypeof RectElement
circletypeof CircleElement
ellipsetypeof EllipseElement
linetypeof LineElement
polylinetypeof PolylineElement
polygontypeof PolygonElement
pathtypeof PathElement
patterntypeof PatternElement
markertypeof MarkerElement
defstypeof DefsElement
linearGradienttypeof LinearGradientElement
radialGradienttypeof RadialGradientElement
stoptypeof StopElement
animatetypeof AnimateElement
animateColortypeof AnimateColorElement
animateTransformtypeof AnimateTransformElement
fonttypeof FontElement
font-facetypeof FontFaceElement
missing-glyphtypeof MissingGlyphElement
glyphtypeof GlyphElement
texttypeof TextElement
tspantypeof TSpanElement
treftypeof TRefElement
atypeof AElement
textPathtypeof TextPathElement
imagetypeof ImageElement
gtypeof GElement
symboltypeof SymbolElement
styletypeof StyleElement
usetypeof UseElement
masktypeof MaskElement
clipPathtypeof ClipPathElement
filtertypeof FilterElement
feDropShadowtypeof FeDropShadowElement
feMorphologytypeof FeMorphologyElement
feCompositetypeof FeCompositeElement
feColorMatrixtypeof FeColorMatrixElement
feGaussianBlurtypeof FeGaussianBlurElement
titletypeof TitleElement
desctypeof DescElement

Defined in

src/Document/elements.ts:47


PSEUDO_ZERO

Const PSEUDO_ZERO: 1e-8

Defined in

src/util/math.ts:3

Functions

vectorMagnitude

vectorMagnitude(v): number

Vector magnitude.

Parameters

NameType
vVectorValue

Returns

number

Number result.

Defined in

src/util/math.ts:10


vectorsRatio

vectorsRatio(u, v): number

Ratio between two vectors.

Parameters

NameType
uVectorValue
vVectorValue

Returns

number

Number result.

Defined in

src/util/math.ts:20


vectorsAngle

vectorsAngle(u, v): number

Angle between two vectors.

Parameters

NameType
uVectorValue
vVectorValue

Returns

number

Number result.

Defined in

src/util/math.ts:30


CB1

CB1(t): number

Parameters

NameType
tnumber

Returns

number

Defined in

src/util/math.ts:34


CB2

CB2(t): number

Parameters

NameType
tnumber

Returns

number

Defined in

src/util/math.ts:38


CB3

CB3(t): number

Parameters

NameType
tnumber

Returns

number

Defined in

src/util/math.ts:42


CB4

CB4(t): number

Parameters

NameType
tnumber

Returns

number

Defined in

src/util/math.ts:46


QB1

QB1(t): number

Parameters

NameType
tnumber

Returns

number

Defined in

src/util/math.ts:50


QB2

QB2(t): number

Parameters

NameType
tnumber

Returns

number

Defined in

src/util/math.ts:54


QB3

QB3(t): number

Parameters

NameType
tnumber

Returns

number

Defined in

src/util/math.ts:58


compressSpaces

compressSpaces(str): string

HTML-safe compress white-spaces.

Parameters

NameTypeDescription
strstringString to compress.

Returns

string

String.

Defined in

src/util/string.ts:8


trimLeft

trimLeft(str): string

HTML-safe left trim.

Parameters

NameTypeDescription
strstringString to trim.

Returns

string

String.

Defined in

src/util/string.ts:17


trimRight

trimRight(str): string

HTML-safe right trim.

Parameters

NameTypeDescription
strstringString to trim.

Returns

string

String.

Defined in

src/util/string.ts:26


toNumbers

toNumbers(str): number[]

String to numbers array.

Parameters

NameTypeDescription
strstringNumbers string.

Returns

number[]

Numbers array.

Defined in

src/util/string.ts:35


toMatrixValue

toMatrixValue(str): MatrixValue

String to matrix value.

Parameters

NameTypeDescription
strstringNumbers string.

Returns

MatrixValue

Matrix value.

Defined in

src/util/string.ts:46


normalizeAttributeName

normalizeAttributeName(name): string

Normalize attribute name.

Parameters

NameTypeDescription
namestringAttribute name.

Returns

string

Normalized attribute name.

Defined in

src/util/string.ts:68


parseExternalUrl

parseExternalUrl(url): string

Parse external URL.

Parameters

NameTypeDescription
urlstringCSS url string.

Returns

string

Parsed URL.

Defined in

src/util/string.ts:81


normalizeColor

normalizeColor(color): string

Transform floats to integers in rgb colors.

Parameters

NameTypeDescription
colorstringColor to normalize.

Returns

string

Normalized color.

Defined in

src/util/string.ts:100


getSelectorSpecificity

getSelectorSpecificity(selector): string

Measure selector specificity.

Parameters

NameTypeDescription
selectorstringSelector to measure.

Returns

string

Specificity.

Defined in

src/util/styles.ts:26