Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @pelevesque/is-point-in with all npm packages installed. Try it out:

var isPointIn = require("@pelevesque/is-point-in")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@pelevesque/is-point-in v0.1.4

Checks if a point is inside a shape.

Build Status Coverage Status JavaScript Style Guide

is-point-in

Checks if a point is inside a shape.

Node Repository

https://www.npmjs.com/package/@pelevesque/is-point-in

Installation

npm install @pelevesque/is-point-in

Tests

CommandDescription
npm test or npm run testAll Tests Below
npm run coverStandard Style
npm run standardCoverage
npm run unitUnit Tests

Methods

  • rectangle Checks if a point is inside a rectangle.
  • circle Checks if a point is inside a circle.

Usage

Initialization

Requiring the Entire Module

const IsPointIn = require('@pelevesque/is-point-in')

Requiring a Specific Method

const IsPointInRectangle = require('@pelevesque/is-point-in').rectangle

Rectangle

// point
const x = 10
const y = 10

// rectangle
const x1 = 5
const y1 = 5
const x2 = 15
const y2 = 15

const result = IsPointIn.rectangle(x, y, x1, y1, x2, y2)
// result === true

Circle

// point
const x = -3.84
const y = 3.22

// circle
const cx = 0
const cy = 0
const cRadius = 5

const result = IsPointIn.circle(x, y, cx, cy, cRadius)
// result === false
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free