npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-pixel-text-renderer

v1.1.3

Published

A react component for rendering strings on canvas elements using a set of characters each defined on a 5 x 5 grid.

Downloads

3

Readme

react-pixel-text-renderer

A reusable react component that renders a string to a canvas element.

News

  • UPDATE - April 9 2021
    • Custom definitions can now define characters on different sized grids.
    • Fixed unnecessary re-rendering due to missing deps in useEffect callback.
  • UPDATE - March 29 2021
    • You can now pass in custom character definitions via the customDefs prop!

Install

npm i react-pixel-text-renderer

Once installed import as follows:

import TextRenderer from 'react-pixel-text-renderer';

The function component can be called without any props like this:

<TextRenderer />

Resulting in the a canvas with some sample text and randomized colors.

It could also be called like this:

<TextRenderer
  bgColor = {'rgba(0,10,50,1)'}
  color = {[230, 0, 190]}
  text={"it's good it's bad it's ugly it's a pixel text renderer."}
  scale={20}
  charSpaces={8}
  animate={true}
/>
  • PROPS

    • customDefs

    • bgColor

      • Accepts any CSS color value. It simply styles the background of the canvas element. Omitting it results in a transparent background.
    • color

      • An optional array of three 8 bit rgb values. It controls the text color. Omitting it results in characters with random colors biased so as to be brighter in order to contrast well against darker backgrounds.
    • text

      • The string to be rendered.
    • wordWrap

      • Expects A boolean. When set to false and charSpaces has been set to some value, wrapping will occur at the character level, meaning words will be broken onto separate lines when they overflow a row.
      • When set to true, words will never be broken and will instead start a new row.
    • charSpaces

      • Defines the number of characters to be drawn horizontally before wrapping to a new row. Setting this to 1 will result in a vertical column of text. Omitting it will size the canvas to fit the length of the input text.
      • If wordWrap has been set to true and charSpaces is less than the length of the longest word in the input text, charSpaces will be internally set to the the length of the longest word.
    • animate

      • Defaults false. If set to true, when the text is rendered it will do so with an animation.
    • scale

      • A multiplier to scale the nominal dimensions of the underlying pixel information to a larger grid.
    • scaleMode

      • Changes the internal CSS styles to either stretch the canvas to the size of the container or obey the absolute dimensions resulting from the scale prop.
      • Expects a string of either 'fixed' or 'auto'.
      • It defaults to auto if the prop is omitted.