Skip to content

Commit 497008d

Browse files
Misc doc updates (#1334)
1 parent 575d45d commit 497008d

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

packages/docs/src/content/docs/guides/migrate-to-v1.mdx

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ The goals of v1 were to:
99
2. Make jimp's API more consistent and easier to use
1010
3. Many constants have been removed and are string value powered by TS
1111

12+
## Async/Sync
13+
14+
In v0 of jimp there were a mix of async and sync methods for export.
15+
In v1 all "export" methods are async.
16+
17+
They have also been renamed:
18+
19+
- `getBufferAsync` -> `getBuffer`
20+
- `getBase64Async` -> `getBase64`
21+
- `writeAsync` -> `write`
22+
1223
## Importing
1324

1425
`Jimp` no longer uses a default export. Instead it uses named exports.

plugins/plugin-blit/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const methods = {
3737
* const image = await Jimp.read("test/image.png");
3838
* const parrot = await Jimp.read("test/party-parrot.png");
3939
*
40-
* image.blit(parrot, x, y);
40+
* image.blit({ src: parrot, x: 10, y: 10 });
4141
* ```
4242
*/
4343
blit<I extends JimpClass>(image: I, options: BlitOptions) {

plugins/plugin-print/src/index.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function xOffsetBasedOnAlignment<I extends JimpClass>(
3939
font: BmFont<I>,
4040
line: string,
4141
maxWidth: number,
42-
alignment: HorizontalAlign,
42+
alignment: HorizontalAlign
4343
) {
4444
if (alignment === HorizontalAlign.LEFT) {
4545
return 0;
@@ -57,7 +57,7 @@ function drawCharacter<I extends JimpClass>(
5757
font: BmFont<I>,
5858
x: number,
5959
y: number,
60-
char: BmCharacter,
60+
char: BmCharacter
6161
) {
6262
if (char.width > 0 && char.height > 0) {
6363
const characterPage = font.pages[char.page];
@@ -84,7 +84,7 @@ function printText<I extends JimpClass>(
8484
x: number,
8585
y: number,
8686
text: string,
87-
defaultCharWidth: number,
87+
defaultCharWidth: number
8888
) {
8989
for (let i = 0; i < text.length; i++) {
9090
const stringChar = text[i]!;
@@ -130,7 +130,7 @@ export const methods = {
130130
* const image = await Jimp.read("test/image.png");
131131
* const font = await Jimp.loadFont(Jimp.FONT_SANS_32_BLACK);
132132
*
133-
* image.print(font, 10, 10, "Hello world!");
133+
* image.print({ font, x: 10, y: 10, text: "Hello world!" });
134134
* ```
135135
*/
136136
print<I extends JimpClass>(
@@ -141,7 +141,7 @@ export const methods = {
141141
}: PrintOptions & {
142142
/** the BMFont instance */
143143
font: BmFont<I>;
144-
},
144+
}
145145
) {
146146
let {
147147
// eslint-disable-next-line prefer-const
@@ -184,7 +184,7 @@ export const methods = {
184184
}
185185

186186
const defaultCharWidth = Object.entries(font.chars).find(
187-
(c) => c[1].xadvance,
187+
(c) => c[1].xadvance
188188
)?.[1].xadvance;
189189

190190
if (typeof defaultCharWidth !== "number") {
@@ -199,7 +199,7 @@ export const methods = {
199199
font,
200200
lineString,
201201
maxWidth,
202-
alignmentX,
202+
alignmentX
203203
);
204204

205205
printText(
@@ -208,7 +208,7 @@ export const methods = {
208208
x + alignmentWidth,
209209
y,
210210
lineString,
211-
defaultCharWidth,
211+
defaultCharWidth
212212
);
213213
y += font.common.lineHeight;
214214
});

0 commit comments

Comments
 (0)