UNPKG

shape-points

Version:

Generate points for simple shapes and curves: arcs, rectangles, rounded rectangles, circles, ellipses, bezierCurveTo, bezierCurveThrough (i.e., bezier curves through specific points)

101 lines (61 loc) 3.12 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Home</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Home</h1> <h3> </h3> <section> <article><h1>shape-points</h1> <p>Generate points for simple shapes and curves: arcs, rectangles, rounded rectangles, circles, ellipses, bezierCurveTo, bezierCurveThrough (i.e., bezier curves through specific points)</p> <h2>rationale</h2> <p>I needed to find the points of a rounded rectangle. Then I had fun adding lots of other shapes and curves.</p> <h2>installation</h2> <pre class="prettyprint source"><code>yarn add shape-points </code></pre> <p>or</p> <pre class="prettyprint source"><code>npm i shape-points </code></pre> <h2>programmatic example</h2> <pre class="prettyprint source lang-js"><code>import * as ShapePoints from 'shape-points' // alternatively: // const roundedRect = require('shape-points').roundedRect const points = ShapePoints.roundedRect(125, 100, 200, 100, 30) // assuming a canvas context was set up context.moveTo(points[0], points[1]) for (let i = 2; i &lt; points.length; i += 2) { context.lineTo(points[i], points[i + 1]) } context.stroke() </code></pre> <h2>live example</h2> <p>https://davidfig.github.io/shape-points/</p> <h2>API</h2> <p>https://davidfig.github.io/shape-points/jsdoc/</p> <h2>License</h2> <p>MIT License<br> (c) 2018 <a href="https://yopeyopey.com/">YOPEY YOPEY LLC</a> by <a href="https://twitter.com/yopey_yopey/">David Figatner</a></p></article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-shape-points.html">shape-points</a></li><li><a href="module-shape-points_arc.html">shape-points/arc</a></li><li><a href="module-shape-points_bezierCurveThrough.html">shape-points/bezierCurveThrough</a></li><li><a href="module-shape-points_bezierCurveTo.html">shape-points/bezierCurveTo</a></li><li><a href="module-shape-points_circle.html">shape-points/circle</a></li><li><a href="module-shape-points_ellipse.html">shape-points/ellipse</a></li><li><a href="module-shape-points_line.html">shape-points/line</a></li><li><a href="module-shape-points_quadraticCurveTo.html">shape-points/quadraticCurveTo</a></li><li><a href="module-shape-points_rect.html">shape-points/rect</a></li><li><a href="module-shape-points_roundedRect.html">shape-points/roundedRect</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Tue Mar 29 2022 14:31:03 GMT-0700 (Pacific Daylight Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>