Skip to content

Commit 6319a9a

Browse files
Merge pull request #98 from renderforest/document-getters-setters-of-project-data
document getters setters of project data
2 parents 2fe78ed + 708b28e commit 6319a9a

File tree

2 files changed

+274
-10
lines changed

2 files changed

+274
-10
lines changed

README.md

Lines changed: 265 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,28 @@ Welcome to the Renderforest API! You can use our API to:
2424
- [Get Project-data](#get-project-data)
2525
- [Update Project-data - partial update](#update-project-data---partial-update)
2626
- [Getters and Setters of Project-data Instance](#getters-and-setters-of-project-data-instance)
27+
* [Getters](#getters)
28+
- [Get project id](#get-project-id)
29+
- [Get template id](#get-template-id)
30+
- [Check whether is equalizer or not](#check-whether-is-equalizer-or-not)
31+
- [Check whether is lego or not](#check-whether-is-lego-or-not)
32+
- [Get title](#get-title)
33+
- [Get mute music](#get-mute-music)
34+
- [Get sounds](#get-sounds)
35+
- [Get theme](#get-theme)
36+
- [Get project colors](#get-project-colors)
37+
- [Get screens](#get-screens)
38+
- [Get screen areas](#get-screen-areas)
39+
- [Get patch object](#get-patch-object)
40+
* [Setters](#setters)
41+
- [Set theme](#set-theme)
42+
- [Set mute music](#set-mute-music)
43+
- [Set sounds](#set-sounds)
44+
- [Set text on text holder area](#set-text-on-text-holder-area)
45+
- [Set image on image holder area](#set-image-on-image-holder-area)
46+
- [Set video on video holder area](#set-video-on-video-holder-area)
47+
- [Set project colors](#set-project-colors)
48+
- [Set screens](#set-screens)
2749
* [Sounds API](#sounds-api)
2850
- [Get All Sounds](#get-all-sounds)
2951
- [Get Recommended Sounds](#get-recommended-sounds)
@@ -307,9 +329,250 @@ See the [Getters and Setters of Project-data Instance](#getters-and-setters-of-p
307329

308330
### Getters and Setters of Project-data Instance
309331

310-
Getters TBA
332+
#### Getters
333+
334+
##### Get project id
335+
```js
336+
projectDataInstance.getProjectId() // 7096113
337+
```
338+
339+
##### Get template id
340+
```js
341+
projectDataInstance.getTemplateId() // 701
342+
```
343+
344+
##### Check whether is equalizer or not
345+
```js
346+
projectDataInstance.isEqualizer() // false
347+
```
348+
349+
##### Check whether is lego or not
350+
```js
351+
projectDataInstance.isLego() // true
352+
```
353+
354+
##### Get title
355+
```js
356+
projectDataInstance.getTitle() // 'Explainer Video Toolkit'
357+
```
358+
359+
##### Get mute music
360+
```js
361+
projectDataInstance.getMuteMusic() // false
362+
```
363+
364+
##### Get sounds
365+
```js
366+
projectDataInstance.getSounds() // Array of sound objects
367+
```
368+
369+
##### Get theme
370+
```js
371+
projectDataInstance.getTheme() // { themeVariableName: 'num', themeVariableValue: '2' }
372+
```
373+
374+
##### Get project colors
375+
```js
376+
projectDataInstance.getProjectColors() // Array of color objects
377+
```
378+
379+
##### Get screens
380+
```js
381+
projectDataInstance.getScreens() // Array of screen objects
382+
```
383+
384+
##### Get screen areas
385+
```js
386+
const screens = projectDataInstance.getScreens()
387+
388+
const firstScreenAreas = screens && screens[0] && screens[0].getAreas() // Array of area objects
389+
```
390+
391+
##### Get patch object
392+
```js
393+
projectDataInstance.getPatchObject() // Object containing local updates. Used to update project-data (partial).
394+
```
395+
396+
397+
#### Setters
398+
399+
##### Set theme
400+
```js
401+
// get theme from .templates API
402+
const theme = {
403+
themeVariableName: 'num',
404+
themeVariableValue: '2'
405+
}
406+
projectDataInstance.setTheme(theme)
407+
```
408+
409+
##### Set mute music
410+
```js
411+
projectDataInstance.setMuteMusic(true)
412+
```
413+
414+
##### Set sounds
415+
```js
416+
// sound from ./sounds API
417+
const sound1 = {
418+
duration: 120,
419+
id: 559,
420+
genre: 'Rock', // optional
421+
lowQuality: 'https://example.com/sample-low.mp3',
422+
path: 'https://example.com/sample.mp3',
423+
title: 'Inspiring Piano'
424+
}
425+
426+
// your own sound
427+
const sound2 = {
428+
duration: 12,
429+
fileSize: 198658,
430+
id: 952626,
431+
path: 'https://example.com/sample.mp3',
432+
title: 'sound sample.mp3',
433+
userId: 1469277,
434+
voiceOver: false
435+
}
436+
437+
const sounds = [ sound1, sound2 ]
438+
projectDataInstance.setSounds(sounds)
439+
```
440+
441+
##### Set text on text holder area
442+
```js
443+
const screens = projectDataInstance.getScreens()
444+
445+
if (screens && screens[0]) {
446+
const areas = screens[0].getAreas()
447+
448+
const area = areas[0]
449+
if (area && area.type === 'text') {
450+
area.setText('sample text')
451+
}
452+
}
453+
```
454+
455+
##### Set image on image holder area
456+
```js
457+
const screens = projectDataInstance.getScreens()
458+
459+
if (screens && screens[1]) {
460+
const areas = screens[1].getAreas()
461+
462+
const area = areas[0]
463+
if (area && area.type === 'image') {
464+
const image = {
465+
fileName: 'sample file name', // optional
466+
mime: 'image/png', // optional
467+
filePath: 'https://example.com/sample.png',
468+
webpPath: 'https://example.com/sample.webp', // optional
469+
fileType: 'image', // optional
470+
thumbnailPath: 'https://example.com/sample-thumbnail.png', // optional
471+
imageCropParams: {
472+
transform: 0,
473+
top: 11,
474+
left: 0,
475+
width: 798,
476+
height: 456
477+
}
478+
}
479+
480+
area.setImage(image)
481+
}
482+
}
483+
```
484+
485+
##### Set video on video holder area
486+
```js
487+
const screens = projectDataInstance.getScreens()
488+
489+
if (screens && screens[2]) {
490+
const areas = screens[2].getAreas()
491+
492+
const area = areas[0]
493+
if (area && area.type === 'video') {
494+
const video = {
495+
fileName: 'sample file name', // optional
496+
mime: 'video/mp4', // optional
497+
filePath: 'https://example.com/sample.png',
498+
webpPath: 'https://example.com/sample.webp', // optional
499+
fileType: 'video', // optional
500+
videoCropParams: {
501+
duration: 6,
502+
mime: 'video/mp4',
503+
thumbnail: 'https://example.com/sample-thumbnail.png',
504+
thumbnailVideo: 'https://example.com/sample-thumbnail-video.mp4',
505+
trims: [0, 2, 3, 5],
506+
volume: {
507+
music: 10,
508+
video: 100
509+
}
510+
}
511+
}
512+
513+
area.setVideo(video)
514+
}
515+
}
516+
```
517+
518+
##### Set project colors
519+
```js
520+
// get project colors from ./templates API
521+
const projectColors = [
522+
{ id: 0, hexCode: 'ffffff' },
523+
{ id: 1, hexCode: 'a1d4ec' },
524+
{ id: 2, hexCode: '1d2e54' },
525+
{ id: 3, hexCode: '61a371' },
526+
{ id: 4, hexCode: 'a0b6e7' },
527+
{ id: 5, hexCode: 'e0d0ef' },
528+
{ id: 6, hexCode: '5c1313' },
529+
{ id: 7, hexCode: 'b2e1f4' },
530+
{ id: 8, hexCode: '706bb5' },
531+
{ id: 9, hexCode: 'b4ddf5' }
532+
]
533+
projectDataInstance.setProjectColors(projectColors)
534+
```
535+
536+
##### Set screens
537+
```js
538+
// get screen from ./templates API
539+
const screen = {
540+
id: 2125620,
541+
characterBasedDuration: true,
542+
compositionName: '191_man_Angry_2',
543+
duration: 5,
544+
extraVideoSecond: 0,
545+
iconAdjustable: 0,
546+
gifPath: 'https://example.com/191_man_Angry_2_1.gif',
547+
gifBigPath: 'https://example.com/191_man_Angry_2_1.gif',
548+
gifThumbnailPath: 'https://example.com/191_man_Angry_2_n.jpg',
549+
hidden: false,
550+
maxDuration: 15,
551+
order: 1900,
552+
path: 'https://example.com/191_man_Angry_2_n.jpg',
553+
tags: 'business, computer, chair, desk, laptop, occupation, office, worker, arms, boss, boy, businessman,chef, company, employer, professional',
554+
title: 'Angry Office worker with arms crossed',
555+
type: 1,
556+
areas: [
557+
{
558+
id: 3562168,
559+
cords: [ 656, 224, 1048, 224, 1048, 332, 656, 332 ],
560+
height: 108,
561+
order: 0,
562+
title: 'char_Angry_2',
563+
type: 'text',
564+
value: '',
565+
wordCount: 40,
566+
width: 392
567+
}
568+
]
569+
}
570+
const _screens = projectDataInstance.getScreens()
571+
_screens.push(screen)
572+
projectDataInstance.setScreens(_screens)
573+
```
574+
311575

312-
Setters TBA
313576

314577
## Sounds API
315578

examples/project-data/update-project-data-partial-advanced.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ async function sample () {
3131
duration: 120,
3232
id: 559,
3333
genre: 'Rock', // optional
34-
lowQuality: 'hosting/file/Sounds/120_second/Inspiring%20Piano%20120%20preview.mp3',
35-
path: 'https://usersounds.rfstat.com/Sounds/120_second/Inspiring%2520Piano%2520120.mp3',
34+
lowQuality: 'https://example.com/sample-low.mp3',
35+
path: 'https://example.com/sample.mp3',
3636
title: 'Inspiring Piano'
3737
}
3838

@@ -41,13 +41,14 @@ async function sample () {
4141
duration: 12,
4242
fileSize: 198658,
4343
id: 952626,
44-
path: 'https://usersounds.rfstat.com/user_1469277/bf69833d-a895-43b4-bedf-f37eeabdc5f7.mp3',
44+
path: 'https://example.com/sample.mp3',
4545
title: 'sound sample.mp3',
4646
userId: 1469277,
4747
voiceOver: false
4848
}
4949

50-
projectDataInstance.setSounds([sound1, sound2])
50+
const sounds = [ sound1, sound2 ]
51+
projectDataInstance.setSounds(sounds)
5152

5253
const screens = projectDataInstance.getScreens()
5354
// set text on text holder area
@@ -134,13 +135,13 @@ async function sample () {
134135
duration: 5,
135136
extraVideoSecond: 0,
136137
iconAdjustable: 0,
137-
gifPath: 'https://static.rfstat.com/media/Screens_2016/3rd_gen_2016/Explainer-Video-Toolkit-3gen/Gif/191_man_Angry_2_1.gif',
138-
gifBigPath: 'https://static.rfstat.com/media/Screens_2016/3rd_gen_2016/Explainer-Video-Toolkit-3gen/Gif/Big-Gif/191_man_Angry_2_1.gif',
139-
gifThumbnailPath: 'https://static.rfstat.com/media/Screens_2016/3rd_gen_2016/Explainer-Video-Toolkit-3gen/Gif/Gif-thumb/191_man_Angry_2_n.jpg',
138+
gifPath: 'https://example.com/191_man_Angry_2_1.gif',
139+
gifBigPath: 'https://example.com/191_man_Angry_2_1.gif',
140+
gifThumbnailPath: 'https://example.com/191_man_Angry_2_n.jpg',
140141
hidden: false,
141142
maxDuration: 15,
142143
order: 1900,
143-
path: 'https://static.rfstat.com/media/Screens_2016/3rd_gen_2016/Explainer-Video-Toolkit-3gen/Screen/191_man_Angry_2_n.jpg',
144+
path: 'https://example.com/191_man_Angry_2_n.jpg',
144145
tags: 'business, computer, chair, desk, laptop, occupation, office, worker, arms, boss, boy, businessman,chef, company, employer, professional',
145146
title: 'Angry Office worker with arms crossed',
146147
type: 1,

0 commit comments

Comments
 (0)