npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@creenv/rectangle

v0.0.1

Published

a lightweight rectangle class, can be used as a bounding rect

Downloads

5

Readme

@creenv/rectangle

A simpel Rectangle class, usually designed to be used as a Boudingt rectangle, but can fit other purposes including rectangles. It can be used with points of n-dimensions, as long as those points are instances of @creenv/Vector or of @creenv/Vector children (such as @creenv/Vector2, @creenv/Vector3, all available in the @creenv/vector package);

How to use

import Vector from '@creenv/vector';
import Rectangle from '@creenv/rectangle';

// top left point
let p1 = new Vector(1.5,1.5),
    p2 = new Vector(3,3);

let rect = new Rectangle(p1, p2);

rect.topleft; // = p1
rect.bottomright; // = p2

rect.contains(new Vector(2,2)); // true
rect.contain(new Vector(-4,2)); // false
rect.contain(p1); // true

Full doc

Following is a full list of availaible methods via the Rectangle class.


constructor (pointA: Vector, pointB: Vector)

The 2 points from opposite corners of the rectangle. It is used to describe a rectangle. It is not required that pointA describes the TOP-LEFT point and pointB the BOTTOM-RIGHT one, but it is advised.

| Name | Type | Def | |---|---|---| pointA | Vector | The top-left point of the rectangle | pointB | Vector | The bottom-right point of the rectangle |


class members

Javascript does not allow class members to be private, by definition they all are public. However, the members tagged as private should not be modified for reasons inherant to Rectangle class behavior.

| Name | Type | Accessibility | Def | |---|---|---|---| .topleft | Vector | private | pointA from the constructor first argument *.bottomright | Vector | private | pointB from the constructor second argument .size | Array. | private | a n-dimensions array, where n is the number of dimensions of pointA dimensions


.contains (point: Vector)

Returns true if point is contained within the rectangle and false if it's not. It is required for such a test that point dimensions matches the number of dimensions of the rectangle.

| Name | Type | Def | |---|---|---|---| point | Vector | point with the same number of dimensions as pointA and pointB, that needs to be tested

See example from part 1 for more informations on this function's usage.