polotno-node 2.6.2 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/video.js +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polotno-node",
3
- "version": "2.6.2",
3
+ "version": "2.6.3",
4
4
  "description": "Polotno workflow from NodeJS",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/video.js CHANGED
@@ -95,15 +95,26 @@ module.exports.jsonToVideo = async function jsonToGifFile(page, json, attrs) {
95
95
  });
96
96
 
97
97
  const fps = 15;
98
+ const timePerFrame = 1000 / fps;
98
99
 
99
100
  // loop through the images and add each to the animation
100
101
  const frames = Math.floor((duration / 1000) * fps);
101
102
  for (let i = 0; i < frames; i++) {
102
- const currentTime = i * 100;
103
+ const currentTime = i * timePerFrame;
103
104
  const dataURL = await page.evaluate(
104
105
  async (json, attrs, currentTime) => {
105
106
  store.setCurrentTime(currentTime + 1);
106
- const url = await store.toDataURL({ ...attrs, pixelRatio: 0.5 });
107
+ const currentPage = store.pages.find((p) => {
108
+ return (
109
+ store.currentTime >= p.startTime &&
110
+ store.currentTime < p.startTime + p.duration
111
+ );
112
+ });
113
+ const url = await store.toDataURL({
114
+ pixelRatio: 0.5,
115
+ ...attrs,
116
+ pageId: currentPage?.id,
117
+ });
107
118
  return url;
108
119
  },
109
120
  json,