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

yy-intersects

v1.0.8

Published

shape collision / intersects library for pixi.js

Downloads

22

Readme

intersects

shape collision / intersects library for pixi.js

rationale

this is a simple libary that i designed for use with my game engine. most of the better collision libraries were too large or too heavily invested in physics. i wanted something simple that worked well with pixi.js.

Code Example

// point-Rectangle intersection

var sprite = new PIXI.Sprite(texture);
sprite.shape = new Intersects.Rectangle(sprite);
sprite.position.set(5, 5);
if (sprite.shape.collidesPoint(new PIXI.Point(10, 10)))
{
    console.log('intersected');
}

Live Example

https://davidfig.github.io/pixi-intersects/

Installation

npm i yy-intersects

API Reference

Classes

Circle

circle shape

Kind: global class

new Circle(article, [options])

| Param | Type | Description | | --- | --- | --- | | article | Article | that uses this shape | | [options] | object | @see Circle.set |

circle.set(options)

Kind: instance method of Circle

| Param | Type | Default | Description | | --- | --- | --- | --- | | options | object | | | | [options.positionObject] | object | this.article | use this to update position | | [options.radius] | number | | otherwise article.width / 2 is used as radius |

circle.update()

update AABB

Kind: instance method of Circle

circle.collidesCircle(circle) ⇒ boolean

Does Circle collide with Circle?

Kind: instance method of Circle

| Param | Type | | --- | --- | | circle | Circle |

circle.collidesPoint(point) ⇒ boolean

Does Circle collide with point?

Kind: instance method of Circle

| Param | Type | | --- | --- | | point | Point |

circle.collidesLine(p1, p2) ⇒ boolean

Does Circle collide with a line? from http://stackoverflow.com/a/10392860/1955997

Kind: instance method of Circle

| Param | Type | | --- | --- | | p1 | Point | | p2 | Point |

circle.collidesRectangle(rectangle)

Does circle collide with Rectangle?

Kind: instance method of Circle

| Param | Type | | --- | --- | | rectangle | Rectangle |

Polygon

Polygon

Kind: global class

new Polygon(article, points, [options])

| Param | Type | Description | | --- | --- | --- | | article | Article | that uses this shape | | points | array | in the form of [x, y, x2, y2, x3, y3, . . .] | | [options] | object | @see Polygon.set |

polygon.set(options)

Kind: instance method of Polygon

| Param | Type | Description | | --- | --- | --- | | options | object | | | options.points | Array.<PIXI.Point> | | | [options.center] | PIXI.DisplayObject | object to use for position (and rotation, unless separately defined) | | [options.rotation] | PIXI.DisplayObject | object to use for rotation instead of options.center or article |

polygon.update()

based on http://www.willperone.net/Code/coderr.php

Kind: instance method of Polygon

polygon.collidesRectangle(rectangle) ⇒ boolean

Does Rectangle collide Rectangle?

Kind: instance method of Polygon

| Param | Type | | --- | --- | | rectangle | Rectangle |

polygon.collidesCircle(circle) ⇒ boolean

Does Rectangle collide Circle?

Kind: instance method of Polygon

| Param | Type | | --- | --- | | circle | Circle |

Rectangle

Kind: global class

new Rectangle(article, [options])

| Param | Type | Description | | --- | --- | --- | | article | object | that uses this shape | | [options] | object | @see Rectangle.set |

rectangle.width

width of rectangle

Kind: instance property of Rectangle

rectangle.height

height of rectangle

Kind: instance property of Rectangle

rectangle.vertices

sets vertices Array[8]

Kind: instance property of Rectangle

rectangle.set(options)

Kind: instance method of Rectangle

| Param | Type | Description | | --- | --- | --- | | options | object | | | [options.width] | number | width of object when aligned | | [options.height] | number | height of object when aligned | | [options.square] | number | side size of a square | | [options.center] | object | object to use for position (and rotation, unless separately defined) | | [options.rotation] | object | object to use for rotation instead of options.center or article | | [options.noRotate] | boolean | object does not rotate (simplifies math) |

rectangle.update()

based on http://www.willperone.net/Code/coderr.php update AABB and sets vertices to dirty

Kind: instance method of Rectangle

rectangle.updateVertices()

updates vertices automatically when dirty

Kind: instance method of Rectangle

rectangle.collidesRectangle(rectangle) ⇒ boolean

Does Rectangle collide Rectangle?

Kind: instance method of Rectangle

| Param | Type | | --- | --- | | rectangle | Rectangle |

rectangle.collidesCircle(circle) ⇒ boolean

Does Rectangle collide Circle?

Kind: instance method of Rectangle

| Param | Type | | --- | --- | | circle | Circle |

Shape

base class of all shapes

Kind: global class

new Shape([article])

| Param | Type | Description | | --- | --- | --- | | [article] | object | that uses this shape |

shape.AABBs(AABB)

collides with this shape's AABB box

Kind: instance method of Shape

| Param | Type | | --- | --- | | AABB | object |

shape.collidesPoint(point) ⇒ boolean

point-polygon collision test based on this.vertices based on http://stackoverflow.com/questions/217578/how-can-i-determine-whether-a-2d-point-is-within-a-polygon/2922778#2922778

Kind: instance method of Shape

| Param | Type | | --- | --- | | point | Point |

shape.collidesPolygon(polygon, isAABB) ⇒ boolean

Does Polygon collide Polygon or AABB? based on http://stackoverflow.com/questions/10962379/how-to-check-intersection-between-2-rotated-rectangles

Kind: instance method of Shape

| Param | Type | | --- | --- | | polygon | Array | | isAABB | boolean |

shape.collidesLine(p1, p2) ⇒ boolean

Does polygon collide Line?

Kind: instance method of Shape

| Param | Type | | --- | --- | | p1 | Point | | p2 | Point |

shape.collides()

catch all for automatic collision checking

Kind: instance method of Shape

Shape.lineLine(p1, p2, p3, p4) ⇒ boolean

Do two lines intersect? from http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect

Kind: static method of Shape

| Param | Type | | --- | --- | | p1 | Point | | p2 | Point | | p3 | Point | | p4 | Point |


Copyright (c) 2016 YOPEY YOPEY LLC - MIT License - Documented by jsdoc-to-markdown