Skip to main content

canvg

Namespaces​

Classes​

Interfaces​

Type Aliases​

CreateCanvas​

Ƭ CreateCanvas: (width: number, height: number) => HTMLCanvasElement | OffscreenCanvas & { getContext: (contextId: "2d") => OffscreenCanvasRenderingContext2D }

Type declaration​

â–¸ (width, height): HTMLCanvasElement | OffscreenCanvas & { getContext: (contextId: "2d") => OffscreenCanvasRenderingContext2D }

Function to create new canvas.

Parameters​
NameType
widthnumber
heightnumber
Returns​

HTMLCanvasElement | OffscreenCanvas & { getContext: (contextId: "2d") => OffscreenCanvasRenderingContext2D }

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:26


IViewBoxConfig​

Ƭ IViewBoxConfig: Omit<IScreenViewBoxConfig, "document">

Defined in​

src/Document/Document.ts:51


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