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

math-understanding-tools

v0.5.1

Published

![Logo](./math-understanding-tools.png)

Downloads

7

Readme

Logo

Purpose of the project

math-understanding-tools has been developed to make demonstration about mathematics.
The core project is based on pixiJS.
It allows to draw some vectors, basic shapes, line, grids, angle, measurement, coordinates (...)
If you are seaching how to explain/represent/draw cos/sin, normalization, etc... to your student, friends, community, (...) you can use this library to simplify the development of your demonstration.

Setup

NPM Install

npm install math-understanding-tools

Basic Usage Example

import { Application } from  "pixi.js";
import { GraphicVector, OVector2, UpdateService } from  "math-understanding-tools";

let options = {
    antialias:true,
    autoResize:true
};

const app    = new Application(options);
const vector = new GraphicVector(app.stage, new OVector2(), new OVector2(100, 50));

document.addEventListener("DOMContentLoaded", init);
window.addEventListener("resize", resize);

function init(_:Event):void {
    app.ticker.add(UpdateService.update);
    document.body.appendChild(app.view);
    resize();
}

function resize(_?:Event):void {
    app.renderer.resize(window.innerWidth, window.innerHeight);
}

Advice (js module management nightmare)

To setup your development environment with the simpliest way, consider using vitejs, snowpack or other solutions.

Benefit of OClass

If you would like to animate your mathematic demo, you can use a tween lib.
The targeted Graphic will schedule a draw in the next frame when a change has been detected.

Let's using GSAP and change the init fonction in the previous code snippet:

// ...
import { gsap } from  "gsap";

// ...
function init(_:Event):void {
    app.ticker.add(UpdateService.update);
    document.body.appendChild(app.view);
    resize();

    let timeline:gsap.core.Timeline = gsap.timeline();
    timeline.to(vector.to, {x:200, y:400, duration:2, delay:1});
    timeline.to(vector.lineStyle, {alpha:0, duration:1});
    timeline.set(vector.lineStyle, {color:0xFF4444});
    timeline.to(vector.lineStyle, {alpha:1, duration:1});
    timeline.to(vector.from, {x:500, y:200, duration:1}, "-=1");
}

MathMap

Global container helping to hierarchize drawings with a lot of method to add graphic things.

Window

Internally using ORectTranform to make interface working for any screen size.

Style

Each graphics has it own default style that you can grab from an instance or from the class.

// from class
GraphicShape.defaultFillStyle

// from instance
let shape:GraphicShape = new GraphicShape(/*aContainerInstance*/);
shape.defaultFillStyle;

The Style object returned by defaultFillStyleProperty is the same for all instance.

If you wish that a particular instance has its own style, consider using following property:
shape.fillStyle

Note: internally, if the fillStyle (or lineStyle) property is not use, the graphic will use the defaultFillStyle.
When you affect a value to fillStyle property or if you use directly the property, the used style becomes the fillStyle.
If you desire after editing a fillStyle property to go back to defaultFillStyle to make your instance looks like the others, affect null or defaultFillStyle to fillStyle property.

// I would like to shape has its own fill style, so, let's using fillStyle prop :
shape.fillStyle.color = 0xFF0000;

// oups, I would like to go back to default fill style :
shape.fillStyle = null;
// or
shape.fillStyle = shape.defaultFillStyle; // or GraphicShape.defaultFillStyle

Note: internally, the fillStyle is not initalized until you use it. If you do not affect your own value, it will be internally initialized with a copy of defaultFillStyle.

Utils

A lot of basic mathematic stuff are here:
OVector2 (Note: static methods will return a new instance while the instance methods will update the targeted instance)
ORectangle
MathTools
UpdateService (for gameloop)
ORectTransform (Same as Unity system)
Feel free to explore and use them