generated from qq15725/starter-ts
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtypes.ts
104 lines (88 loc) · 2.16 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Application Extension
export interface Application {
identifier: string
code: string
data: number[]
}
// Graphic Control Extension
export interface GraphicControl {
delayTime: number // unit: 10ms
transparentIndex: number
// ↓ <Packed Fields>
reserved: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
disposal: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
userInput: boolean
transparent: boolean
// ↑ <Packed Fields>
}
// Comment Extension
export type Comment = string
// Plain Text Extension
export interface PlainText {
left: number
top: number
width: number
height: number
cellWidth: number
cellHeight: number
colorIndex: number
backgroundColorIndex: number
data: number[]
}
// Image Descriptor
export interface Frame {
left: number
top: number
width: number
height: number
// ↓ <Packed Fields>
localColorTable: boolean
interlaced: boolean
reserved: 0 | 1 | 2 | 3
colorTableSorted: boolean
colorTableSize: number
// ↑ <Packed Fields>
// Local Color Table - [r, g, b][]
colorTable?: number[][]
// LZW Minimum Code Size
lzwMinCodeSize: number
// Image Data - [begin, length][]
dataPositions: number[][]
// Extensions (89a)
application?: Application
graphicControl?: GraphicControl
comment?: Comment
plainText?: PlainText
// Custom fields
index: number
delay: number // unit: 1ms
disposal: GraphicControl['disposal']
}
export type EncodingFrame = Partial<Frame> & { data: Uint8ClampedArray, transparent?: boolean }
export type UnencodedFrame = Partial<Frame> & { data: CanvasImageSource | BufferSource | string }
export interface Gif87a {
// Logical Screen Descriptor
width: number
height: number
// ↓ <Packed Fields>
globalColorTable: boolean
colorResoluTion: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
colorTableSorted: boolean
colorTableSize: number
// ↑ <Packed Fields>
backgroundColorIndex: number
pixelAspectRatio: number
// Global Color Table
colorTable?: number[][]
// Image Descriptor
frames: Frame[]
}
export interface Gif89a extends Gif87a {
// Application Extension
// NETSCAPE2.0
looped?: boolean
loopCount?: number
}
export interface Gif extends Gif89a {
version: '89a' | '87a'
}