GithubHelp home page GithubHelp logo

nelix / bare-minimum-2d Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mithi/bare-minimum-2d

1.0 1.0 0.0 1.38 MB

An extremely lightweight React component to declare and render points, lines, ellipses, and polygons

Home Page: https://bare-minimum-2d.netlify.app

License: MIT License

HTML 2.56% JavaScript 94.09% CSS 3.36%

bare-minimum-2d's Introduction

A Bare Minimum 2D Plotter

An extremely lightweight React component for plotting points, lines, ellipses, and polygons on an inline SVG

NPM MINIFIED GZIPPED

Demo Applications

Responsive Illustrations On-The-Fly Animations Interactive Applications
demo demo demo
source code source code source code

Install

npm install --save bare-minimum-2d

Usage

This is an example of what you can pass to a BareMinimum2d component. You pass it like so:

import BareMinimum2d from 'bare-minimum-2d'

<div style={{ width: '100%', height: '100vh' }}>
  <BareMinimum2d {...{ data, container }} />
</div>

The component takes the dimensions of its parent and is always centered

Everything you need to know explained in two minutes

A BareMinimum2d component only has two props: container and data. container is a small hash-like type object with exactly four elements. data is an array containing hash-like objects.

Example:

import BareMinimum2d from 'bare-minimum-2d'

const container = {
  color: '#0000FF',
  opacity: 0.2,
  xRange: 300,
  yRange: 500
}

const data = [{
  x: [0],
  y: [-20],
  color: "#FFFFFF",
  opacity: 1.0,
  size: 10,
  type: 'points',
  id: 'center'
}]

<div style={{ width: "100%", height: "100vh" }}>
  <BareMinimum2d {...{ data, container }} />
</div>

container.color and container.opacity specifies the canvas color of BareMinimum2d.

The cartesian coordinate system of BareMinimum will follow the diagram below given container.xRange and container.yRange. Position (0, 0) will always be at the center of the rendered component.

                  yRange/2
                     |
                     |
  -xRange/2 -------(0,0)--------- xRange/2
                     |
                     |
                   -yRange/2

Please take a look at more complex example data prop to get the idea.

Each element of the array data should be a hash-like objectwith a type key which should have a value that is one of the following:

points ellipse lines polygons
plural singular plural singular

Elements of the data array will be stacked based on the order they are declared. The first element will be at the most bottom layer while the last element of the array will be at the top.

All attributes are ALWAYS required, nothing is optional because there are no default values. The id attribute must be unique for each element of the data array.

END

Contributing

PRs welcome! Please read the contributing guidelines and the commit style guide else your PR might not be merged ๐Ÿ™.

License

MIT ยฉ Mithi

bare-minimum-2d's People

Contributors

mithi avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.