Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjirou/rectangle-state
Generate a state meaning a rectangle as a plane object
https://github.com/kjirou/rectangle-state
Last synced: 12 days ago
JSON representation
Generate a state meaning a rectangle as a plane object
- Host: GitHub
- URL: https://github.com/kjirou/rectangle-state
- Owner: kjirou
- License: mit
- Created: 2017-01-12T15:42:15.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-08-31T07:30:50.000Z (about 3 years ago)
- Last Synced: 2024-10-25T20:11:05.867Z (14 days ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rectangle-state
[![npm version](https://badge.fury.io/js/rectangle-state.svg)](https://badge.fury.io/js/rectangle-state)
Generate a state meaning a rectangle as a plane object
## Installation
```bash
npm install rectangle-state
```## Usage
```js
const { createRectangleState, toXYWidthHeight } = require('rectangle-state');console.log(
createRectangleState({ top: 1, right: 12, bottom: 2, left: 11 })
); // -> { top: 1, right: 12, bottom: 2, left: 11 }console.log(
createRectangleState({ x: 11, y: 1, width: 1, height: 1 })
); // -> { top: 1, right: 12, bottom: 2, left: 11 }console.log(
toXYWidthHeight(
createRectangleState({ top: 1, right: 12, bottom: 2, left: 11 })
)
); // -> { x: 11, y: 1, width: 1, height: 1 }// Error - The `x` is mixed.
//createRectangleState({ top: 1, right: 12, bottom: 2, left: 11, x: 1 });// Error - The `top` is greater than the `bottom`.
//createRectangleState({ top: 100, right: 12, bottom: 2, left: 11 });
```