diff --git a/packages/canvas-video/README.md b/packages/canvas-video/README.md index ec117a2..775fb54 100644 --- a/packages/canvas-video/README.md +++ b/packages/canvas-video/README.md @@ -2,32 +2,31 @@ - snapshots of the canvas can be exported as video to fit the frame + + ## Getting Started ```js import CanvasVideo from '@kjojs/canvas-video'; -const TEN_MINUTES = 1000 * 60 * 10 +const TEN_MINUTES = 1000 * 60 * 10; +const canvasWidth = 300; +const canvasHeight = 200; const canvasVideo = new CanvasVideo({ - canvas: { - width: 200, - height: 200, - }, - video: { - totalTime: TEN_MINUTES, - frameRate: 60, - }, - render: (ctx, { - frameOrder, // starting from 1 - time, // milliseconds - percent, // if totalTime is empty, it's always zero - }) => { - const rotateAngle = (frameOrder * Math.PI) / 3; + totalTime: TEN_MINUTES, + frameRate: 60, + width: canvasWidth, + height: canvasHeight, + className: '_video', + render: (ctx, { sequence }) => { + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.clearRect(0, 0, canvasWidth, canvasHeight); - ctx.clearRect(0, 0, 200, 200); - ctx.rotate(rotateAngle); + ctx.translate(canvasWidth / 2, canvasHeight / 2); + ctx.rotate(0.04 * sequence); + ctx.translate(0, 0); ctx.fillStyle = '#000000'; - ctx.fiilRect(10, 10, 180, 180); + ctx.fillRect(-50, -50, 100, 100); }, }); diff --git a/packages/canvas-video/assets/demo_video.gif b/packages/canvas-video/assets/demo_video.gif new file mode 100644 index 0000000..f40d683 Binary files /dev/null and b/packages/canvas-video/assets/demo_video.gif differ diff --git a/packages/canvas-video/examples/index.css b/packages/canvas-video/examples/index.css index cc3d82c..d3650fd 100644 --- a/packages/canvas-video/examples/index.css +++ b/packages/canvas-video/examples/index.css @@ -119,3 +119,13 @@ section h3 { margin: 0 auto; background-color: #fff; } +.btn_play { + padding: 0 0 10px; + text-align: center; +} +.desc { + padding: 20px 0; + text-align: center; + font-size: 16px; + white-space: pre-wrap; +} diff --git a/packages/canvas-video/examples/index.html b/packages/canvas-video/examples/index.html index 7cc2b95..64de92a 100644 --- a/packages/canvas-video/examples/index.html +++ b/packages/canvas-video/examples/index.html @@ -7,15 +7,19 @@
-