Giter Site home page Giter Site logo

rishi8991 / react-polygon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from peteroid/react-polygon

0.0 1.0 1.0 502 KB

A react add-on for drawing polygons for any number of sides, as well as animation

Home Page: https://peteroid.github.io/react-polygon/

JavaScript 74.76% CSS 11.32% HTML 13.92%

react-polygon's Introduction

Standard - JavaScript Style Guide Build Status npm version

react-polygon react-polygon

A react add-on for drawing polygons for any number of sides, as well as animation

Demo

https://peteroid.github.io/react-polygon/

Usage

npm install react-polygon --save
import Polygon from 'react-polygon'

// add this to your components
<Polygon />

Build your own

npm install
npm run webpack

Props

name : propType = defaultValue

Basic

  • n : number = 3
  • size : number = 50
  • fill : string = "#ad893e"
  • ratios : [number] = [1, 1, 1, 1, 1]

Animation

  • isAnimating : bool = true
  • duration : number = 1000

renderPoint

You can render extra elements on each point by passing a function to the props renderPoint. Here is an example for rendering a point on each vertice:

import React, { Component } from 'react'
import Polygon from 'react-polygon'

class MyPolygon extends Component {
  myRenderPoint (point) {
    return (
      <circle cx={point[0]} cy={point[1]} r={5} />
    )
  }

  render () {
    return (
      <Polygon renderPoint={this.myRenderPoint} />
    )
  }
}

Credits

react-polygon's People

Contributors

peteroid avatar

Watchers

James Cloos avatar

Forkers

jboetticher

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.