# penrose-triangle-js

> An animated Penrose triangle for your browser.

Latest version **1.0.4** (published 2019-10-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install penrose-triangle-js
pnpm add penrose-triangle-js
yarn add penrose-triangle-js
bun add penrose-triangle-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-10-09 |
| First published | 2019-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 73.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Albert Lobo |
| Maintainers | llop |
| Keywords | penrose-triangle, animation, front-end, web |

## Links

- npm: https://www.npmjs.com/package/penrose-triangle-js
- Repository: https://github.com/llop/penrose-triangle-js
- Homepage: http://albertlobo.com/general/animated-penrose-triangle
- Issues: https://github.com/llop/penrose-triangle-js/issues
- npm.io page: https://npm.io/package/penrose-triangle-js

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2019-10-09
- 1.0.3 — 2019-10-09
- 1.0.2 — 2019-10-09
- 1.0.1 — 2019-10-09
- 1.0.0 — 2019-10-09

## README

penrose-triangle-js
===================

Drawing inspiration from the [Penrose triangle](https://en.wikipedia.org/wiki/Penrose_triangle), 
this project provides an optical illusion consisting of several cubes that move along an impossible triangular path.

![Image](penrose-triangle.png)

## Quick start

Options to add `penrose-triangle-js` to your project:
* Install with [npm](https://npmjs.org): `npm install penrose-triangle-js`
* [Download the latest release](https://github.com/llop/penrose-triangle-js/archive/master.zip)
* Clone the repo: `git clone https://github.com/llop/penrose-triangle-js.git`

## Basic use

In the HTML file, a `canvas` is required to display the animation.

```html
<canvas id='penrose-canvas' width='400' height='350'></canvas>
```

To use `penrose-triangle-js`, just import the script and start the animation.

```html
<script src='penrose-triangle.js'></script>
<script>
  // start the animation when the page loads
  window.onload = () => {
    const canvas = document.getElementById('penrose-canvas');
    const penroseTriangle = new PenroseTrinagle(canvas);
    penroseTriangle.start();
  };
</script>
```

## Advanced use

It is possible to customize the animation by providing an `options` object to the `PenroseTriangle` constructor. 
The default options are:

```javascript
{
  triangleEdge: 300,        // length of triangle's edge in pixels
  cubeEdge: 30,             // length of cube's edge in pixels
  cubesPerTriangleEdge: 6,  // # of cubes per triangle edge
  padding: [ 50.5, 0.5 ],   // top and left padding in pixels
  loopFrames: 100,          // # of frames per loop
  lineWidth: 3,             // cube line's width in pixels
  lineColor: '#0041a3',     // cube line's color
  cubeColors: [             // colors for the cube's visible faces
    '#4f9bf7', 
    '#c0d8fc', 
    '#87b7ff' 
  ]
}
```

## License

`penrose-triangle-js` is released under the MIT License. See [LICENSE](LICENSE) for details.

---
_Source: https://npm.io/package/penrose-triangle-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
