1.0.2 • Published 3 years ago

react-image-shapes v1.0.2

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

react-image-shapes

Give different shapes for your image

NPM JavaScript Style Guide

Install

npm install --save react-image-shapes

Usage

import React, { Component } from 'react'

import ReactImageShapes from 'react-image-shapes'

class Example extends Component {
  render() {
    return <ReactImageShapes 
        image="https://s3-us-west-2.amazonaws.com/uw-s3-cdn/wp-content/uploads/sites/6/2017/11/04133712/waterfall.jpg" 
        width="300px"
        height="300px"
        type="cut-top-left"
        cutPercentage={20}
        mode="y"
      />
  }
}

Online demo

Demo

Props

NameRequiredDescription
imageTrueSpecify the url of the image
widthFalseSpecify the width of the image. By defualt it is unset
heightFalseSpecify the height of the image. By defualt it is unset
typeTrueSpecify the type of the image (find the options in Defualt Shapes section)
cutPercentageFalseSpecify the percentage of cut to the image (applies only at 4 type of shapes, see Default Shapes section for more details)
modeFalseType 'x' if you want to cut in vertical way, Type 'y' to cut in horizontal way

Default Shapes

You can use one of the following types for your image

typecutPercentagemode
cut-top-leftNumber of percentage example: 20'x' or 'y'
cut-top-rightNumber of percentage example: 20'x' or 'y'
cut-bottom-leftNumber of percentage example: 20'x' or 'y'
cut-bottom-rightNumber of percentage example: 20'x' or 'y'
triangle\ \
trapezoid\ \
parallelogram\ \
rhombus\ \
pentagon\ \
hexagon\ \
heptagon\ \
octagon\ \
decagon\ \
bevel\ \
rabbet\ \
left-arrow\ \
right-arrow\ \
left-point\ \
right-point\ \
left-chevron\ \
right-chevron\ \
star\ \
cross\ \
message\ \
close\ \
frame\ \
circle\ \
ellipse\ \

Example of use:

import React, { Component } from 'react'

import ReactImageShapes from 'react-image-shapes'

class Example extends Component {
  render() {
    return <ReactImageShapes 
        image="https://s3-us-west-2.amazonaws.com/uw-s3-cdn/wp-content/uploads/sites/6/2017/11/04133712/waterfall.jpg" 
        width="300px"
        height="300px"
        type="triangle"
      />
  }
}

License

MIT © aborova8