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

@sschepis/tiny-physics

v0.1.0

Published

A tiny javascript physics engine

Downloads

5

Readme

Tiny Physics - a tiny(ish) Javascript physics engine

Introduction

Tiny physics is a javascript physics engine. It's small but not even the smallest or anything.

Usage

Creating a world

Physics.create({
    objects: (function () {
        var objects = [];
        for (let i = 0; i < 50; i++) {
            var x = 50 + Math.random() * 800
            var y = 50 + Math.random() * 600
            var radius = 50// + Math.random() * 10;
            objects.push({
                type: "polygon",
                points: Polygon.createPolygon(x, y, radius, ~~(Math.random() * 5) + 3),
                x,
                y,
                vx: 0,
                vy: 0,
                ax: 0,
                ay: 0,
                mass: 1,
                radius,
                color: "#ff000055",
                lineWidth: 1
            });
        }
        return objects;
    })(),
    forces: [
        Physics.forces.gravity(50, 2000, 980),
        Physics.forces.repulsion(1, 50, 98),
        Physics.forces.overlapResolver()
    ],
    viewport: {
        width: 1920,
        height: 1080,
        x: 0,
        y: 0
    },
    size: {
        width: 1920,
        height: 1080
    },
});
Physics.resume();

installation

npm install tiny-physics

API

Physics.create(options)

Creates a new physics world. Options are:

  • objects - an array of objects to be added to the world
  • forces - an array of forces to be applied to the world
  • viewport - an object describing the viewport
  • size - an object describing the size of the world

Physics.resume()

Resumes the world

Physics.pause()

Pauses the world

Physics.add(object)

Adds an object to the world

Physics.remove(object)

Removes an object from the world

Physics.addForce(force)

Adds a force to the world

Physics.removeForce(force)

Removes a force from the world

Physics.forces

A collection of predefined forces. See [forces.js](

Physics.objects

A collection of predefined objects. See [objects.js](

Physics.objects.createPolygon(x, y, radius, sides)

Creates a polygon with the specified number of sides

License

MIT

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Contact

  • [Github](