-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpitft.d.ts
191 lines (166 loc) · 7.14 KB
/
pitft.d.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// Type definitions for pitft
// Definitions by: Peter Müller <https://crycode.de/>
/// <reference types="node" />
declare module "pitft" {
/**
* Creates a new PiTFT instance.
* @param {string} device The framebuffer device. (e.g. /dev/fb1)
* @param {boolean} doubleBuffering True if you want to use double buffering.
*/
function pitft (device: string, doubleBuffering?: boolean): pitft.FrameBuffer;
namespace pitft {
interface FrameBuffer {
/**
* Returns an object with the size of the display.
*/
size (): {
/**
* Width of the display.
*/
width: number;
/**
* Height of the display.
*/
height: number;
};
/**
* Returns the raw data as a Buffer.
*/
data (): Buffer;
/**
* Clears the display.
*/
clear (): void;
/**
* Transfers the current Buffer to the display.
* Must be called in double buffering mode.
*/
blit (): void;
/**
* Selects a pattern for the next drawings.
* @param {number} patternID ID of the pattern.
*/
color (patternID: number): void;
/**
* Selects a color for the nex drawings.
* @param {number} r Red (from 0.0 to 1.0)
* @param {number} g Green (from 0.0 to 1.0)
* @param {number} b Blue (from 0.0 to 1.0)
*/
color (r: number, g: number, b: number): void;
/**
* Creates a new linear pattern and returns the pattern ID.
* Start and end coordinates are absolute to the display size.
* @param {number} x0 Start x of the linear pattern.
* @param {number} y0 Start y of the linear pattern.
* @param {number} x1 End x of the linear pattern.
* @param {number} y2 End y of the linear pattern.
* @return {number} The ID of the new pattern.
*/
patternCreateLinear (x0: number, y0: number, x1: number, y2: number) : number;
/**
* Creates a new linear pattern and returns the pattern ID.
* Start and end coordinates are absolute to the display size.
* @param {number} patternID ID, which the pattern will get. Old patterns with this ID will be replaced.
* @param {number} x0 Start x of the linear pattern.
* @param {number} y0 Start y of the linear pattern.
* @param {number} x1 End x of the linear pattern.
* @param {number} y2 End y of the linear pattern.
* @return {number} The ID of the new pattern.
*/
patternCreateLinear (patternID: number, x0: number, y0: number, x1: number, y2: number) : number;
/**
* Creates a new RGBA pattern and returns the pattern ID.
* @param {number} r Red (from 0.0 to 1.0)
* @param {number} g Green (from 0.0 to 1.0)
* @param {number} b Blue (from 0.0 to 1.0)
* @param {number} a (optional) Alpha from 0.0 to 1.0)
* @return {number} The ID of the new pattern.
*/
patternCreateRGB (r: number, g: number, b: number, a?: number): number;
/**
* Creates a new RGBA pattern and returns the pattern ID.
* @param {number} patternID ID, which the pattern will get. Old patterns with this ID will be replaced.
* @param {number} r Red (from 0.0 to 1.0)
* @param {number} g Green (from 0.0 to 1.0)
* @param {number} b Blue (from 0.0 to 1.0)
* @param {number} a (optional) Alpha (from 0.0 to 1.0)
* @return {number} The ID of the new pattern.
*/
patternCreateRGB (patternID: number, r: number, g: number, b: number, a?: number): number;
/**
* Adds a color stop to a linear pattern.
* @param {number} patternID ID of the pattern.
* @param {number} offset Offset in the linear pattern. (from 0.0 to 1.0)
* @param {number} r Red (from 0.0 to 1.0)
* @param {number} g Green (from 0.0 to 1.0)
* @param {number} b Blue (from 0.0 to 1.0)
* @param {number} a (optional) Alpha (from 0.0 to 1.0)
*/
patternAddColorStop (patternID: number, offset: number, r: number, g: number, b: number, a?: number): void;
/**
* Destroyes a pattern to free up memory.
* A destroyed pattern cannot be used anymore.
* @param {number} patternID [description]
*/
patternDestroy (patternID: number): void;
/**
* Fills the display with the currently selected color or pattern.
*/
fill (): void;
/**
* Creates a line using the currently selected color or pattern.
* @param {number} x0 Start x
* @param {number} y0 Start y
* @param {number} x1 End x
* @param {number} y1 End y
* @param {number} width (optional) Line width.
*/
line (x0: number, y0: number, x1: number, y1: number, width?: number): void;
/**
* Creates a rectangel using the currently selected color or pattern.
* @param {number} x Start x
* @param {number} y Start y
* @param {number} width Width
* @param {number} height Height
* @param {boolean} outline (optional) true to draw only the border.
* @param {number} borderWidth (optional) Width of the border if outline is true.
*/
rect (x: number, y: number, width: number, height: number, outline?: boolean, borderWidth?: number): void;
/**
* Creates a circle using the currently selected color or pattern.
* @param {number} x Center x
* @param {number} y Center y
* @param {number} radius Radius
* @param {boolean} outline (optional) true to draw only the border.
* @param {boolean} borderWidth (optional) Width of the border if outline is true.
*/
circle (x: number, y: number, radius: number, outline?: boolean, borderWidth?: boolean): void;
/**
* Selects a font.
* @param {string} fontName The font name.
* @param {number} fontSize The font size.
* @param {boolean} fontBold (optional) true to draw the font bold.
*/
font (fontName: string, fontSize: number, fontBold?: boolean): void;
/**
* Creates a text using the currently selected color or pattern.
* @param {number} x Start x
* @param {number} y Start y (baseline)
* @param {string} text The text
* @param {boolean} centered (optional) true to draw the text centered to the start coordinates.
* @param {number} rotation (optional) Rotation of the text in degrees.
* @param {boolean} right (optional) true to draw the text rigth aligned to the start coordinates.
*/
text (x: number, y: number, text: string, centered?: boolean, rotation?: number, right?: boolean): void;
/**
* Draws an image.
* @param {number} x Start x
* @param {number} y Start y
* @param {string} path Path to the image file.
*/
image (x: number, y: number, path: string): void;
}
}
export = pitft;
}