Skip to content

Commit e201a55

Browse files
samples: update the example of setting text, image, video.
1 parent 8eef9ec commit e201a55

File tree

1 file changed

+43
-42
lines changed

1 file changed

+43
-42
lines changed

samples/project-data/set-text-image-video.js

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,53 @@ const RenderforestClient = require('../../lib/client')
1010

1111
const Renderforest = new RenderforestClient({ signKey: '<signKey>', clientId: -1 })
1212

13-
Renderforest.getProjectData(15220886)
13+
Renderforest.getProjectData(16165971)
1414
.then((projectDataInstance) => {
15-
const firstScreen = projectDataInstance.getScreen(0)
16-
const firstAreaFirstScreen = firstScreen.getArea(0)
17-
console.log(firstAreaFirstScreen.getRecommendedCharacterCount())
18-
firstAreaFirstScreen.setText('sample-text')
15+
// check area type
16+
console.log(projectDataInstance.getScreen(0).getArea(0).getAreaType())
17+
projectDataInstance.getScreen(0)
18+
.getArea(0)
19+
.setText('sample-text')
20+
.setTextScale(120)
1921

20-
const secondScreen = projectDataInstance.getScreen(1)
21-
const firstAreaSecondScreen = secondScreen.getArea(0)
22-
console.log(firstAreaSecondScreen.getAreaType())
23-
firstAreaSecondScreen.setImage({
24-
fileName: 'sample file name', // optional
25-
mime: 'image/png', // optional
26-
filePath: 'https://example.com/sample.png',
27-
webpPath: 'https://example.com/sample.webp', // optional
28-
fileType: 'image', // optional
29-
thumbnailPath: 'https://example.com/sample-thumbnail.png', // optional
30-
imageCropParams: {
31-
transform: 0,
32-
top: 11,
33-
left: 0,
34-
width: 798,
35-
height: 456
36-
}
37-
})
22+
projectDataInstance.getScreen(1)
23+
.getArea(0)
24+
.setImage({
25+
fileName: 'sample file name', // optional
26+
mime: 'image/png', // optional
27+
filePath: 'https://example.com/sample.png',
28+
webpPath: 'https://example.com/sample.webp', // optional
29+
fileType: 'image', // optional
30+
thumbnailPath: 'https://example.com/sample-thumbnail.png', // optional
31+
imageCropParams: {
32+
transform: 0,
33+
top: 11,
34+
left: 0,
35+
width: 798,
36+
height: 456
37+
}
38+
})
3839

39-
const thirdScreen = projectDataInstance.getScreen(2)
40-
const firstAreaThirdScreen = thirdScreen.getArea(0)
41-
firstAreaThirdScreen.setVideo({
42-
fileName: 'sample file name', // optional
43-
mime: 'video/mp4', // optional
44-
filePath: 'https://example.com/sample.png',
45-
webpPath: 'https://example.com/sample.webp', // optional
46-
fileType: 'video', // optional
47-
videoCropParams: {
48-
duration: 6,
49-
mime: 'video/mp4',
50-
thumbnail: 'https://example.com/sample-thumbnail.png',
51-
thumbnailVideo: 'https://example.com/sample-thumbnail-video.mp4',
52-
trims: [0, 2, 3, 5],
53-
volume: {
54-
music: 10,
55-
video: 100
40+
projectDataInstance.getScreen(2)
41+
.getArea(0)
42+
.setVideo({
43+
fileName: 'sample file name', // optional
44+
mime: 'video/mp4', // optional
45+
filePath: 'https://example.com/sample.png',
46+
webpPath: 'https://example.com/sample.webp', // optional
47+
fileType: 'video', // optional
48+
videoCropParams: {
49+
duration: 6,
50+
mime: 'video/mp4',
51+
thumbnail: 'https://example.com/sample-thumbnail.png',
52+
thumbnailVideo: 'https://example.com/sample-thumbnail-video.mp4',
53+
trims: [0, 2, 3, 5],
54+
volume: {
55+
music: 10,
56+
video: 100
57+
}
5658
}
57-
}
58-
})
59+
})
5960

6061
return projectDataInstance.save()
6162
})

0 commit comments

Comments
 (0)