You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

rectangle-overlap

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rectangle-overlap

Computes the area of the intersection of two rectangles.

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
4.2K
11.35%
Maintainers
1
Weekly downloads
 
Created
Source

rectangle-overlap

TypeScript support License

Fastly compute the intersection of two rectangles.

Usage

const intersection = require("rectangle-overlap");

let rect1 = {x: 0, y: 0, width: 10, height: 10};
let rect2 = {x: 2, y: 3, width: 42, height: 42};

const overlap = intersection(rect1, rect2);

if (overlap) {
  console.log(`The rectangles overlap over an area of ${overlap.area}`);
  console.log(
    `Intersection coordinates: x=${overlap.x}, y=${overlap.y}, width=${overlap.width}, height=${overlap.height}`,
  )
} else {
  console.log("The rectangles do not overlap");
}

Keywords

rectangle

FAQs

Package last updated on 27 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts