imagescript 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -4
- package/dist/animation.d.ts +92 -7
- package/dist/animation.js +49 -19
- package/dist/codecs/exif.js +62 -0
- package/dist/codecs/gif.js +32 -19
- package/dist/codecs/jpeg.js +13 -1
- package/dist/codecs/png.js +85 -21
- package/dist/codecs/quantize.js +2 -2
- package/dist/codecs/tga.js +47 -4
- package/dist/codecs/vp8l.js +27 -30
- package/dist/codecs/webp.js +23 -10
- package/dist/frame.d.ts +30 -2
- package/dist/frame.js +20 -9
- package/dist/gif.d.ts +10 -7
- package/dist/gif.js +7 -5
- package/dist/image-type.d.ts +1 -0
- package/dist/image-type.js +1 -0
- package/dist/image.d.ts +231 -31
- package/dist/image.js +111 -50
- package/dist/index.d.ts +14 -4
- package/dist/index.js +6 -4
- package/dist/metadata.d.ts +35 -0
- package/dist/metadata.js +43 -0
- package/dist/render/svg.js +39 -21
- package/dist/util/optimize.js +264 -0
- package/dist/util/options.js +3 -0
- package/dist/util/resample.js +44 -26
- package/dist/util/utf8.js +4 -51
- package/dist/version.js +1 -1
- package/package.json +9 -2
- package/dist/codecs/crc.d.ts +0 -9
- package/dist/codecs/exif.d.ts +0 -11
- package/dist/codecs/gif.d.ts +0 -44
- package/dist/codecs/jpeg.d.ts +0 -35
- package/dist/codecs/png.d.ts +0 -97
- package/dist/codecs/quantize.d.ts +0 -25
- package/dist/codecs/tga.d.ts +0 -16
- package/dist/codecs/tiff.d.ts +0 -6
- package/dist/codecs/vp8-tables.d.ts +0 -10
- package/dist/codecs/vp8.d.ts +0 -8
- package/dist/codecs/vp8l.d.ts +0 -62
- package/dist/codecs/webp.d.ts +0 -67
- package/dist/codecs/zlib.d.ts +0 -22
- package/dist/render/font.d.ts +0 -92
- package/dist/render/hinting.d.ts +0 -110
- package/dist/render/svg.d.ts +0 -11
- package/dist/render/text.d.ts +0 -63
- package/dist/util/blur.d.ts +0 -13
- package/dist/util/resample.d.ts +0 -12
- package/dist/util/utf8.d.ts +0 -5
- package/dist/version.d.ts +0 -1
package/dist/codecs/tga.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Whether the data looks like a TGA. Older TGAs have no signature, so this checks that the header is consistent
|
|
3
|
-
*/
|
|
4
|
-
export declare function isTGA(d: Uint8Array): boolean;
|
|
5
|
-
/**
|
|
6
|
-
* Decodes a TGA into RGBA
|
|
7
|
-
*/
|
|
8
|
-
export declare function decode(d: Uint8Array): {
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
pixels: Uint8Array;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Encodes RGBA pixels into a run length encoded TGA (32 bit with alpha, 24 bit if opaque), top left origin
|
|
15
|
-
*/
|
|
16
|
-
export declare function encode(rgba: Uint8Array, width: number, height: number): Uint8Array;
|
package/dist/codecs/tiff.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* VP8 constant tables, extracted from RFC 6386 ("VP8 Data Format and Decoding Guide", sections 9.6, 11.5, 13.4,
|
|
3
|
-
* 13.5 and 14.1). Copyright (c) 2010, 2011 Google Inc., BSD license (see THIRD_PARTY_NOTICES.md)
|
|
4
|
-
*/
|
|
5
|
-
export declare const KF_BMODE_PROBS: Uint8Array<ArrayBuffer>;
|
|
6
|
-
export declare const COEFF_UPDATE_PROBS: Uint8Array<ArrayBuffer>;
|
|
7
|
-
export declare const DEFAULT_COEFF_PROBS: Uint8Array<ArrayBuffer>;
|
|
8
|
-
export declare const DC_QLOOKUP: Uint8Array<ArrayBuffer>;
|
|
9
|
-
export declare const AC_QLOOKUP: Int16Array<ArrayBuffer>;
|
|
10
|
-
export declare const PCAT: Uint8Array<ArrayBuffer>[];
|
package/dist/codecs/vp8.d.ts
DELETED
package/dist/codecs/vp8l.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* WebP lossless (VP8L) bitstream, as specified in RFC 9649 ("WebP Image Format") section 3 onwards, including its
|
|
3
|
-
* table of short distance codes. Copyright (c) 2024 IETF Trust and the persons identified as the document authors,
|
|
4
|
-
* Revised BSD License (see THIRD_PARTY_NOTICES.md)
|
|
5
|
-
*/
|
|
6
|
-
/** decoded VP8L image: ARGB pixels (0xAARRGGBB) */
|
|
7
|
-
export interface VP8LImage {
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
argb: Uint32Array;
|
|
11
|
-
hasAlpha: boolean;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* LSB-first bit reader
|
|
15
|
-
*/
|
|
16
|
-
export declare class BitReader {
|
|
17
|
-
data: Uint8Array;
|
|
18
|
-
pos: number;
|
|
19
|
-
private buffer;
|
|
20
|
-
private count;
|
|
21
|
-
constructor(data: Uint8Array, offset?: number);
|
|
22
|
-
private fill;
|
|
23
|
-
/** reads up to 24 bits */
|
|
24
|
-
read(bits: number): number;
|
|
25
|
-
/** the next 24 bits without consuming them */
|
|
26
|
-
peek(): number;
|
|
27
|
-
skip(bits: number): void;
|
|
28
|
-
/** whether reading went past the end of the data */
|
|
29
|
-
get overrun(): boolean;
|
|
30
|
-
}
|
|
31
|
-
/** canonical prefix code as lookup table */
|
|
32
|
-
export interface PrefixCode {
|
|
33
|
-
table: Int32Array;
|
|
34
|
-
/** set if the code has a single symbol (which takes zero bits) */
|
|
35
|
-
single: number;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Builds a lookup table from code lengths (RFC 9649 section 3.7.2.1.1: canonical codes, read LSB first)
|
|
39
|
-
*/
|
|
40
|
-
export declare function buildCode(lengths: ArrayLike<number>, size: number): PrefixCode;
|
|
41
|
-
/** reads one symbol */
|
|
42
|
-
export declare function readSymbol(reader: BitReader, code: PrefixCode): number;
|
|
43
|
-
/**
|
|
44
|
-
* Reads the VP8L header (signature, dimensions)
|
|
45
|
-
*/
|
|
46
|
-
export declare function readHeader(data: Uint8Array): {
|
|
47
|
-
width: number;
|
|
48
|
-
height: number;
|
|
49
|
-
hasAlpha: boolean;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Decodes a VP8L bitstream (the payload of a VP8L chunk)
|
|
53
|
-
*/
|
|
54
|
-
export declare function decode(data: Uint8Array): VP8LImage;
|
|
55
|
-
/**
|
|
56
|
-
* Decodes transforms and the main image from the bit reader (used by the ALPH chunk too, which has no header)
|
|
57
|
-
*/
|
|
58
|
-
export declare function decodeStream(reader: BitReader, width: number, height: number): Uint32Array;
|
|
59
|
-
/**
|
|
60
|
-
* Encodes ARGB pixels into a VP8L bitstream (the payload of a VP8L chunk)
|
|
61
|
-
*/
|
|
62
|
-
export declare function encode(argb: Uint32Array, width: number, height: number): Uint8Array;
|
package/dist/codecs/webp.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export interface WebPFrame {
|
|
2
|
-
x: number;
|
|
3
|
-
y: number;
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
/** milliseconds */
|
|
7
|
-
duration: number;
|
|
8
|
-
/** whether the frame is alpha blended onto the canvas (false: it replaces the covered area) */
|
|
9
|
-
blend: boolean;
|
|
10
|
-
/** whether the frame's area is cleared to transparent after it was shown */
|
|
11
|
-
dispose: boolean;
|
|
12
|
-
/** RGBA */
|
|
13
|
-
pixels: Uint8Array;
|
|
14
|
-
}
|
|
15
|
-
export interface WebPAnimation {
|
|
16
|
-
width: number;
|
|
17
|
-
height: number;
|
|
18
|
-
/** 0 = forever */
|
|
19
|
-
loopCount: number;
|
|
20
|
-
/** ARGB background color hint (decoders, like browsers, are free to ignore it) */
|
|
21
|
-
background: number;
|
|
22
|
-
frames: WebPFrame[];
|
|
23
|
-
}
|
|
24
|
-
/** Whether the WebP is animated */
|
|
25
|
-
export declare function isAnimated(data: Uint8Array): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Decodes a still WebP into RGBA pixels. Animated WebPs decode to their first frame composited on the canvas
|
|
28
|
-
*/
|
|
29
|
-
export declare function decode(data: Uint8Array): {
|
|
30
|
-
width: number;
|
|
31
|
-
height: number;
|
|
32
|
-
pixels: Uint8Array;
|
|
33
|
-
orientation: number;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Decodes an animated WebP into its frames (not composited); still WebPs become a single frame
|
|
37
|
-
*/
|
|
38
|
-
export declare function decodeAnimation(data: Uint8Array, onlyFirstFrame?: boolean): WebPAnimation;
|
|
39
|
-
/**
|
|
40
|
-
* Composites animation frames onto the canvas like browsers do (transparent background, the background color hint
|
|
41
|
-
* is ignored as the spec allows)
|
|
42
|
-
*/
|
|
43
|
-
export declare function composite({ width, height, frames }: WebPAnimation): Array<{
|
|
44
|
-
pixels: Uint8Array;
|
|
45
|
-
duration: number;
|
|
46
|
-
}>;
|
|
47
|
-
/**
|
|
48
|
-
* Encodes RGBA pixels into a lossless WebP
|
|
49
|
-
*/
|
|
50
|
-
export declare function encode(rgba: Uint8Array, width: number, height: number): Uint8Array;
|
|
51
|
-
export interface WebPEncodeFrame {
|
|
52
|
-
x: number;
|
|
53
|
-
y: number;
|
|
54
|
-
width: number;
|
|
55
|
-
height: number;
|
|
56
|
-
/** milliseconds */
|
|
57
|
-
duration: number;
|
|
58
|
-
/** whether the frame's area is cleared after it was shown */
|
|
59
|
-
dispose: boolean;
|
|
60
|
-
/** RGBA, alpha blended onto the canvas */
|
|
61
|
-
pixels: Uint8Array;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Encodes frames into a lossless animated WebP. Frame offsets have to be even (the format stores them halved)
|
|
65
|
-
* @param plays How often to play the animation, 0 = forever
|
|
66
|
-
*/
|
|
67
|
-
export declare function encodeAnimation(frames: WebPEncodeFrame[], width: number, height: number, plays: number): Uint8Array;
|
package/dist/codecs/zlib.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* zlib deflate/inflate, derived from fflate (https://github.com/101arrowz/fflate)
|
|
3
|
-
* Copyright (c) 2020 Arjun Barrett, MIT License (see THIRD_PARTY_NOTICES.md)
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Compresses data into a zlib stream
|
|
7
|
-
* @param level compression level 0-9
|
|
8
|
-
*/
|
|
9
|
-
export declare function compress(data: Uint8Array, level: number): Uint8Array;
|
|
10
|
-
/**
|
|
11
|
-
* Decompresses a zlib stream into at most limit bytes
|
|
12
|
-
*/
|
|
13
|
-
export declare function decompress(data: Uint8Array, limit: number): Uint8Array;
|
|
14
|
-
/**
|
|
15
|
-
* Compresses data into a zlib stream, with the runtime's native zlib when available
|
|
16
|
-
* @param level compression level 0-9
|
|
17
|
-
*/
|
|
18
|
-
export declare function compressAsync(data: Uint8Array, level: number): Promise<Uint8Array>;
|
|
19
|
-
/**
|
|
20
|
-
* Decompresses a zlib stream into at most limit bytes, using the runtime's native zlib when available
|
|
21
|
-
*/
|
|
22
|
-
export declare function decompressAsync(data: Uint8Array, limit: number): Promise<Uint8Array>;
|
package/dist/render/font.d.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A path command in font units (y up) or user units:
|
|
3
|
-
* ['M', x, y], ['L', x, y], ['Q', cx, cy, x, y], ['C', c1x, c1y, c2x, c2y, x, y], ['Z']
|
|
4
|
-
*/
|
|
5
|
-
export type PathCommand = [string, ...number[]];
|
|
6
|
-
/** a TrueType glyph's points (font units) and instructions, for hinting */
|
|
7
|
-
export interface GlyfPoints {
|
|
8
|
-
xs: number[];
|
|
9
|
-
ys: number[];
|
|
10
|
-
/** on curve flags */
|
|
11
|
-
on: boolean[];
|
|
12
|
-
/** index of the last point of every contour */
|
|
13
|
-
ends: number[];
|
|
14
|
-
instructions: Uint8Array;
|
|
15
|
-
/** glyph bounding box minimum x (the left side bearing's reference) */
|
|
16
|
-
xMin: number;
|
|
17
|
-
/** components of composite glyphs (their points are not included in xs/ys) */
|
|
18
|
-
components: Array<{
|
|
19
|
-
glyph: number;
|
|
20
|
-
dx: number;
|
|
21
|
-
dy: number;
|
|
22
|
-
matrix: [number, number, number, number];
|
|
23
|
-
round: boolean;
|
|
24
|
-
match: [number, number] | null;
|
|
25
|
-
useMetrics: boolean;
|
|
26
|
-
}> | null;
|
|
27
|
-
}
|
|
28
|
-
interface CFF {
|
|
29
|
-
charStrings: Uint8Array[];
|
|
30
|
-
globalSubrs: Uint8Array[];
|
|
31
|
-
privateFor: (glyph: number) => {
|
|
32
|
-
subrs: Uint8Array[];
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Parses TrueType (glyf) and OpenType (CFF) fonts, including the first font of a collection
|
|
37
|
-
*/
|
|
38
|
-
export declare class Font {
|
|
39
|
-
data: Uint8Array;
|
|
40
|
-
view: DataView;
|
|
41
|
-
tables: Record<string, {
|
|
42
|
-
offset: number;
|
|
43
|
-
length: number;
|
|
44
|
-
}>;
|
|
45
|
-
unitsPerEm: number;
|
|
46
|
-
indexToLocFormat: number;
|
|
47
|
-
ascender: number;
|
|
48
|
-
descender: number;
|
|
49
|
-
lineGap: number;
|
|
50
|
-
numberOfHMetrics: number;
|
|
51
|
-
numGlyphs: number;
|
|
52
|
-
outlines: 'glyf' | 'cff';
|
|
53
|
-
cff: CFF | null;
|
|
54
|
-
cmap: (codepoint: number) => number;
|
|
55
|
-
outlineCache: Map<number, PathCommand[]>;
|
|
56
|
-
/** kerning between two glyphs in font units, null if the font has none */
|
|
57
|
-
kerning: ((left: number, right: number) => number) | null;
|
|
58
|
-
constructor(data: Uint8Array);
|
|
59
|
-
u8(o: number): number;
|
|
60
|
-
i8(o: number): number;
|
|
61
|
-
u16(o: number): number;
|
|
62
|
-
i16(o: number): number;
|
|
63
|
-
u32(o: number): number;
|
|
64
|
-
i32(o: number): number;
|
|
65
|
-
/**
|
|
66
|
-
* @param {number} codepoint
|
|
67
|
-
* @return {number} glyph index, 0 (.notdef) if the font has no glyph for it
|
|
68
|
-
*/
|
|
69
|
-
glyphIndex(codepoint: number): number;
|
|
70
|
-
/**
|
|
71
|
-
* @param {number} glyph
|
|
72
|
-
* @return {number} advance width in font units
|
|
73
|
-
*/
|
|
74
|
-
advance(glyph: number): number;
|
|
75
|
-
/** left side bearing in font units */
|
|
76
|
-
leftSideBearing(glyph: number): number;
|
|
77
|
-
/**
|
|
78
|
-
* A TrueType glyph's points and instructions (null for empty glyphs or CFF fonts)
|
|
79
|
-
*/
|
|
80
|
-
glyfPoints(glyph: number): GlyfPoints | null;
|
|
81
|
-
/**
|
|
82
|
-
* @param {number} glyph
|
|
83
|
-
* @return {Array} path commands in font units
|
|
84
|
-
*/
|
|
85
|
-
outline(glyph: number): PathCommand[];
|
|
86
|
-
glyfOutline(glyph: number, depth: number): PathCommand[];
|
|
87
|
-
simpleGlyph(offset: number, contourCount: number): PathCommand[];
|
|
88
|
-
compositeGlyph(offset: number, depth: number): PathCommand[];
|
|
89
|
-
cffOutline(glyph: number): PathCommand[];
|
|
90
|
-
}
|
|
91
|
-
export declare function contourToPath(path: PathCommand[], xs: ArrayLike<number>, ys: ArrayLike<number>, flags: ArrayLike<number | boolean>, first: number, last: number): void;
|
|
92
|
-
export {};
|
package/dist/render/hinting.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* TrueType hinting interpreter. Where the TrueType specification leaves details open, its behavior and parts of its
|
|
3
|
-
* logic follow FreeType's TrueType interpreter (src/truetype/ttinterp.c): fixed point rounding, original distances
|
|
4
|
-
* on the unscaled outline (IP, IUP, MDRP, MD), the IUP interpolation, the movement along near-perpendicular vectors
|
|
5
|
-
* and the tolerance of invalid references. Portions of this software are copyright © 2026 The FreeType Project
|
|
6
|
-
* (https://freetype.org). All rights reserved. FreeType License, see THIRD_PARTY_NOTICES.md and licenses/FTL.txt
|
|
7
|
-
*/
|
|
8
|
-
import { Font, PathCommand } from './font.js';
|
|
9
|
-
interface Vector {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
}
|
|
13
|
-
interface GraphicsState {
|
|
14
|
-
pv: Vector;
|
|
15
|
-
fv: Vector;
|
|
16
|
-
dv: Vector;
|
|
17
|
-
rp0: number;
|
|
18
|
-
rp1: number;
|
|
19
|
-
rp2: number;
|
|
20
|
-
zp0: number;
|
|
21
|
-
zp1: number;
|
|
22
|
-
zp2: number;
|
|
23
|
-
loop: number;
|
|
24
|
-
minimumDistance: number;
|
|
25
|
-
cvtCutIn: number;
|
|
26
|
-
singleWidthCutIn: number;
|
|
27
|
-
singleWidth: number;
|
|
28
|
-
deltaBase: number;
|
|
29
|
-
deltaShift: number;
|
|
30
|
-
autoFlip: boolean;
|
|
31
|
-
/** null: rounding off */
|
|
32
|
-
round: {
|
|
33
|
-
period: number;
|
|
34
|
-
phase: number;
|
|
35
|
-
threshold: number;
|
|
36
|
-
} | null;
|
|
37
|
-
instructControl: number;
|
|
38
|
-
}
|
|
39
|
-
interface Zone {
|
|
40
|
-
curX: Float64Array;
|
|
41
|
-
curY: Float64Array;
|
|
42
|
-
orgX: Float64Array;
|
|
43
|
-
orgY: Float64Array;
|
|
44
|
-
/** unscaled original positions (font units), measurements between original glyph points use them */
|
|
45
|
-
orusX: Float64Array;
|
|
46
|
-
orusY: Float64Array;
|
|
47
|
-
touchX: Uint8Array;
|
|
48
|
-
touchY: Uint8Array;
|
|
49
|
-
on: Uint8Array;
|
|
50
|
-
ends: number[];
|
|
51
|
-
}
|
|
52
|
-
interface FunctionDef {
|
|
53
|
-
code: Uint8Array;
|
|
54
|
-
start: number;
|
|
55
|
-
end: number;
|
|
56
|
-
}
|
|
57
|
-
/** state of a font at one size, after the font and control value programs ran */
|
|
58
|
-
interface SizeState {
|
|
59
|
-
ppem: number;
|
|
60
|
-
/** 26.6 units per font unit */
|
|
61
|
-
scale: number;
|
|
62
|
-
/** the same as 16.16 fixed point number */
|
|
63
|
-
scaleFixed: number;
|
|
64
|
-
cvt: Float64Array;
|
|
65
|
-
storage: Int32Array;
|
|
66
|
-
state: GraphicsState;
|
|
67
|
-
twilight: Zone;
|
|
68
|
-
functions: Map<number, FunctionDef>;
|
|
69
|
-
instructions: Map<number, FunctionDef>;
|
|
70
|
-
/** set if the font and control value programs failed, the font is then rendered unhinted */
|
|
71
|
-
broken: boolean;
|
|
72
|
-
}
|
|
73
|
-
export interface HintedGlyph {
|
|
74
|
-
/** outline in pixels, relative to the pen position (y up) */
|
|
75
|
-
path: PathCommand[];
|
|
76
|
-
/** advance width in whole pixels */
|
|
77
|
-
advance: number;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Executes TrueType instructions for one font
|
|
81
|
-
*/
|
|
82
|
-
export declare class Hinter {
|
|
83
|
-
font: Font;
|
|
84
|
-
fpgm: Uint8Array;
|
|
85
|
-
prep: Uint8Array;
|
|
86
|
-
cvt: Int16Array;
|
|
87
|
-
maxStack: number;
|
|
88
|
-
maxStorage: number;
|
|
89
|
-
maxTwilight: number;
|
|
90
|
-
sizes: Map<number, SizeState>;
|
|
91
|
-
/** 26.6 units per font unit (16.16 fixed point) of the glyph being loaded */
|
|
92
|
-
private scaleFixed;
|
|
93
|
-
constructor(font: Font);
|
|
94
|
-
/** whether the font has hinting instructions (a font program, control value program or control values) */
|
|
95
|
-
get hasInstructions(): boolean;
|
|
96
|
-
private size;
|
|
97
|
-
/**
|
|
98
|
-
* Hints a glyph at a size
|
|
99
|
-
* @param size pixels per em
|
|
100
|
-
* @return the hinted outline, or null if the glyph can't be hinted (it is then rendered unhinted)
|
|
101
|
-
*/
|
|
102
|
-
glyph(glyph: number, size: number): HintedGlyph | null;
|
|
103
|
-
/**
|
|
104
|
-
* Loads, scales and hints a glyph (recursively for composites)
|
|
105
|
-
* @return the glyph zone (with 4 phantom points after the outline points)
|
|
106
|
-
*/
|
|
107
|
-
private load;
|
|
108
|
-
private phantoms;
|
|
109
|
-
}
|
|
110
|
-
export {};
|
package/dist/render/svg.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {string|Uint8Array} source
|
|
3
|
-
* @param {number} mode 1 = scale by size, 2 = fit width to size, 3 = fit height to size
|
|
4
|
-
* @param {number} size
|
|
5
|
-
* @return {{width: number, height: number, pixels: Uint8Array}}
|
|
6
|
-
*/
|
|
7
|
-
export declare function render(source: string | Uint8Array, mode: number, size: number): {
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
pixels: Uint8Array;
|
|
11
|
-
};
|
package/dist/render/text.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* The Rasterizer class is translated from font-rs (https://github.com/raphlinus/font-rs)
|
|
3
|
-
* Copyright 2015 Google Inc., Apache License 2.0 (see THIRD_PARTY_NOTICES.md and licenses/Apache-2.0.txt)
|
|
4
|
-
*/
|
|
5
|
-
import { PathCommand } from './font.js';
|
|
6
|
-
export interface Layout {
|
|
7
|
-
maxWidth: number;
|
|
8
|
-
maxHeight: number;
|
|
9
|
-
wrapStyle: 'word' | 'char';
|
|
10
|
-
horizontalAlign: 'left' | 'center' | 'right';
|
|
11
|
-
verticalAlign: 'top' | 'middle' | 'bottom';
|
|
12
|
-
wrapHardBreaks: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface GlyphBitmap {
|
|
15
|
-
data: Uint8Array;
|
|
16
|
-
width: number;
|
|
17
|
-
height: number;
|
|
18
|
-
/** offset from the pen position */
|
|
19
|
-
left: number;
|
|
20
|
-
/** offset above the baseline */
|
|
21
|
-
top: number;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Lays out and rasterizes text
|
|
25
|
-
* Lines start at ceil(ascender) and advance by ceil(ascender - descender + lineGap); glyphs are placed with
|
|
26
|
-
* subpixel precision using their advance widths and the font's kerning; the canvas spans from the origin to the
|
|
27
|
-
* furthest glyph edge
|
|
28
|
-
* @param {Uint8Array} data TrueType/OpenType font
|
|
29
|
-
* @param {number} size font size in pixels per em
|
|
30
|
-
* @param {string} text
|
|
31
|
-
* @param {Layout} layout
|
|
32
|
-
* @param hinting Whether to run TrueType fonts' hinting instructions, the glyphs of hinted fonts are then placed on
|
|
33
|
-
* whole pixels (fonts without instructions render as without hinting)
|
|
34
|
-
* @return {{width: number, height: number, coverage: Uint8Array}}
|
|
35
|
-
*/
|
|
36
|
-
export declare function render(data: Uint8Array, size: number, text: string, layout: Layout, hinting?: boolean): {
|
|
37
|
-
width: number;
|
|
38
|
-
height: number;
|
|
39
|
-
coverage: Uint8Array;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Rasterizes a glyph outline into an 8-bit coverage bitmap
|
|
43
|
-
* @param {Array} path outline in font units (y up)
|
|
44
|
-
* @param {number} scale pixels per font unit
|
|
45
|
-
* @param {number} [offset=0] horizontal subpixel offset
|
|
46
|
-
* @return {{data: Uint8Array, width: number, height: number, left: number, top: number}|null}
|
|
47
|
-
* left/top position the bitmap relative to the pen position on the baseline (top is measured upwards)
|
|
48
|
-
*/
|
|
49
|
-
export declare function rasterizeGlyph(path: PathCommand[], scale: number, offset?: number): GlyphBitmap | null;
|
|
50
|
-
/**
|
|
51
|
-
* Signed area coverage rasterizer: every line segment adds its area to an accumulation buffer,
|
|
52
|
-
* a prefix sum over each row yields the coverage
|
|
53
|
-
*/
|
|
54
|
-
export declare class Rasterizer {
|
|
55
|
-
width: number;
|
|
56
|
-
height: number;
|
|
57
|
-
accumulation: Float32Array;
|
|
58
|
-
constructor(width: number, height: number);
|
|
59
|
-
line(x0: number, y0: number, x1: number, y1: number): void;
|
|
60
|
-
quad(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): void;
|
|
61
|
-
cubic(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void;
|
|
62
|
-
coverage(): Uint8Array;
|
|
63
|
-
}
|
package/dist/util/blur.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Blurs premultiplied RGBA float pixels in place
|
|
3
|
-
* @param sigma standard deviation of the gaussian in pixels
|
|
4
|
-
*/
|
|
5
|
-
export declare function gaussianBlur(pixels: Float32Array, width: number, height: number, sigma: number): void;
|
|
6
|
-
/**
|
|
7
|
-
* Converts 8-bit RGBA to premultiplied floats
|
|
8
|
-
*/
|
|
9
|
-
export declare function premultiply(rgba: Uint8ClampedArray): Float32Array;
|
|
10
|
-
/**
|
|
11
|
-
* Converts premultiplied floats back to 8-bit RGBA (the clamped output rounds)
|
|
12
|
-
*/
|
|
13
|
-
export declare function unpremultiply(pixels: Float32Array, out: Uint8ClampedArray): void;
|
package/dist/util/resample.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface Filter {
|
|
2
|
-
/** radius of the filter at scale 1 */
|
|
3
|
-
support: number;
|
|
4
|
-
weight: (x: number) => number;
|
|
5
|
-
}
|
|
6
|
-
export declare const BOX: Filter;
|
|
7
|
-
export declare const TRIANGLE: Filter;
|
|
8
|
-
export declare const CUBIC: Filter;
|
|
9
|
-
/**
|
|
10
|
-
* Resamples RGBA pixels with the given filter, in premultiplied alpha so transparent pixels don't bleed their color
|
|
11
|
-
*/
|
|
12
|
-
export declare function resample(src: Uint8ClampedArray, width: number, height: number, outWidth: number, outHeight: number, filter: Filter, out: Uint8ClampedArray): void;
|
package/dist/util/utf8.d.ts
DELETED
package/dist/version.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const VERSION = "3.1.0";
|