-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(canvas-video): add feature - play (no-issue)
- Loading branch information
1 parent
b0a7f8b
commit 703a85a
Showing
13 changed files
with
363 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,35 @@ | ||
import CanvasVideo from '../src'; | ||
|
||
async function main() { | ||
new CanvasVideo({ | ||
width: 300, | ||
ratio: 3 / 2, | ||
const TEN_MINUTES = 1000 * 60 * 10; | ||
const canvasWidth = 300; | ||
const canvasHeight = 200; | ||
const canvasVideo = new CanvasVideo({ | ||
totalTime: TEN_MINUTES, | ||
frameRate: 60, | ||
width: canvasWidth, | ||
height: canvasHeight, | ||
className: '_video', | ||
render: () => {}, | ||
}).insertUnder(document.getElementById('base_example') as HTMLElement); | ||
render: (ctx, { sequence }) => { | ||
ctx.setTransform(1, 0, 0, 1, 0, 0); | ||
ctx.clearRect(0, 0, canvasWidth, canvasHeight); | ||
|
||
ctx.translate(canvasWidth / 2, canvasHeight / 2); | ||
ctx.rotate(0.04 * sequence); | ||
ctx.translate(0, 0); | ||
ctx.fillStyle = '#000000'; | ||
ctx.fillRect(-50, -50, 100, 100); | ||
}, | ||
}); | ||
|
||
canvasVideo.insertUnder(document.getElementById('base_example') as HTMLElement); | ||
|
||
document.querySelector('._btnPlay')!.addEventListener('click', () => { | ||
canvasVideo.play(); | ||
}); | ||
|
||
(document.querySelector('#base_desc') as HTMLElement).innerText = | ||
'The above element is not a <canvas>, The <video>.\nclick Play button!'; | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.