0.0.1 • Published 3 years ago

react-pixelate v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

This repo is to pixelate Images and HTML Element for React.

This repo is inspired by react-pixelify. ImagePixelated is a typescript version of Pixelify.

Components

  • ImagePixelated
  • ElementPixelated

Installation

Using npm:

npm install react-pixelate

OR using yarn:

yarn add react-pixelate

Demo

Usage

Import components

import { ImagePixelated, ElementPixelated } from "react-pixelate"

1. ImagePixelated

// Import image you want to pixelate
// import src from "./img.png"

<div className="App">
  <ImagePixelated src={src} width={500} height={300} fillTransparencyColor={"grey"} />
</div>
Properties
PropertyTypeDefault ValueDescriptionRequired
srcStringSource of the imageYes
widthIntImage original widthProp to override the original widthNo
heightIntImage original heightProp to override the original heightNo
pixelSizeInt5Size of the pixel in the new pixelated imageNo
centeredBoolfalseIf true, the pixels grid will be centered vertically and horizontally. Example: You choose a pixelSize of 10, but your image width or height cant be divided by an exact grid of 10x10 pixels. Setting this prop as true will set an offset that keeps the grid centeredNo
fillTransparencyColorStringwhiteFor images with transparency (e.g png image), you can set a value for the places where the image is transparentNo

2. ElementPixelated

<div className="App">
  <ElementPixelated pixelSize={5}>
    <div style={{ height: 200, width: 1000 }}>
      Text here, or any child element (including image)
    </div>
  </ElementPixelated>
</div>
Properties
PropertyTypeDefault ValueDescriptionRequired
childrenJSX.Elementelement inside body of ElementPixelated componentElement want to be pixelatedNo
pixelSizeInt5Size of the pixel in the new pixelated elementNo