0.0.6 • Published 6 years ago

@jworkshop/canvasasciifier v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

canvasasciifier

A \<pre> text React component which renders ascii from a canvas.

NPM version build status node version npm download

install

NPM

Usage

import React, { Component } from "react";
import ReactDOM from "react-dom";

import CanvasAsciifier from "@jworkshop/canvasasciifier";

import "./style.css";

class Example extends Component {
  someFunction() {
    const { myCanvas, myAsciifier } = this;

    /** Get the pre element with the generated ascii text. */
    myAsciifier.getTextElement();

    /** Update the pre element with generated ascii text. */
    asciifier.update(myCanvas);

    /** Generate ascii text from the canvas image data. */
    let asciiCode = myAsciifier.generateAsciiCode(myCanvas);
  }

  render() {

    return (
      <canvas
        ref={myCanvas => this.myCanvas = myCanvas}
      />
      <CanvasAsciifier
        ref={myAsciifier => this.myAsciifier = myAsciifier}
        className="className"
        style={ ... }
        textClassName="textClassName"
        textStyle={ ... }
        invert={true}
        asciiData={[" ", ".", ",", ";", "|", "*", "%", "@", "X", "#", "W", "M"]}
      />
    );
  }
}

ReactDOM.render(<Test />, document.getElementById("root"));
0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago