Giter Site home page Giter Site logo

houdiini / canvas-image-scrubber Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anni-platform/canvas-image-scrubber

0.0 1.0 0.0 10.01 MB

A react component to render video-like playback for image sequences

Home Page: https://anni-platform.github.io/canvas-image-scrubber/

JavaScript 100.00%

canvas-image-scrubber's Introduction

canvas-image-scrubber

npm version

*Currently under heavy development. API will probably change

A react component to render video-like playback for image sequences ๐ŸŽฅ.

View Demo

Installation

Via NPM:

npm install canvas-image-scrubber

or Yarn:

yarn add canvas-image-scrubber

Basic Usage with webpack and file-loader

frames is a required prop which must be an array of valid image paths to each frame of your image sequence.

render is also a required prop. It is a render-prop which allows you to render the image sequence player, controls, playback progress bar, and audio controls however you wish. See below for basic usage, and ./demo/src/index.js for more advanced usage with prop getters getViewerControlsProps and getViewerProgressProps.

More robust documentation will hopefully be coming soon.. ๐Ÿค 

import React from 'react';
import CanvasImageScrubber from 'canvas-image-scrubber';
export function getFrames() {
  let i = 1;
  const frames = [];
  while (i < 39) {
    frames.push(require(`./frames/Frame-${i}.jpg`));
    i++;
  }
  return frames;
}

const frames = getFrames();

function MyApp() {
  render() {
    <CanvasImageScrubber
      frames={frames}
      render={({ renderViewer }) => {
        return (
          <div>
            {renderViewer}
          </div>
        )
      }}
    />
  }
}

Optionally render your own canvas element

The render props provided in the render prop callback provide a getCanvasRef which will allow you to render your own canvas element should you need to do so. Use getCanvasRef as the value for the prop ref on your canvas element, this way canvas-image-scrubber can get a dom reference to your canvas element. Usage example:

function MyApp() {
  render() {
    <CanvasImageScrubber
      frames={frames}
      render={({ getCanvasRef }) => {
        return (
          <div>
            <canvas ref={getCanvasRef} />
          </div>
        )
      }}
    />
  }
}

[npm-badge]: https://img.shields.io/npm/v/npm-package.png?style=flat-square
[npm]: https://www.npmjs.com/package/canvas-image-scrubber

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.