GithubHelp home page GithubHelp logo

wind's Introduction

Wind -- An abstraction over user-input

Wind is a library part of my ongoing exploration of the computer as a digital art form. Wind exposes a concept called a pointer, which takes the place of the position vector often used physics simulations, games and drawing programs. While this library is primarily developed for use in drawing programs, it's completely independent of this concept, and can be used in all kinds of programs.

Additionally, wind is completely decoupled from any rendering technology, feel free to use it with svg, html elements or the canvas. Note however, the library is based around 2D positions, 3D is not supported.

What does it do?

Wind exposes a concept called a pointer which takes the place of the position vector often used in games or physics simulations. This decoupling of the position from the physics-objects comes with a few nice advantages. First of all, motions are completely reusable and configurable.

Because the pointers are separate objects from the rendered objects, it is possible to manipulate them in more interesting ways than traditional position attributes. This additional flexibility is the primary reason this library was developed. For example, you can start playing around with "mirrors", where the cursor is mirrored using various symmetries.

Another possibility is to use simple mouse motions to spawn large amounts of pointers, which can then be used for particles, vine or tree-like growth, throwing chains and all kinds of other interesting stuff.

The key takeaway here is that one renderable object can be reused with all these kinds of interesting configurable motions. When the library grows, a simple function

function drawCircle(ctx) {
    ctx.beginPath();
    ctx.arc(this.position[0], this.position[1], 5, 0, 2 * Math.PI);
    ctx.closePath();
    ctx.color = "skyblue";
    ctx.fill();
}

Can be recycled as a cursor, a stamp-like brush, a particle for a particle gun all with predefined cursor behaviors with exactly the same API.

A project like this is best explained with demos, so I advise you to look through the annotated demos page. (WIP)

Unfortunately, most written here is the intent of the library, right now, only few motions exist, and experimentation with symmetries and particle spawners needs to be done before all this is possible. As stated in the head of this readme, this library is part of my ongoing exploration of the computer as a digital art form.

What's in the box?

There are a few pre-defined motions available.

Cursor

There's the cursor pointer, which tracks the mouse's position.

Stalker

The stalker follows behind the mouse [demo](no demo available yet!) with a short delay. Every frame, it moves n% closer to its target, usually the mouse. This results in a very smooth motion useful for all kinds of tracking behavior.

Examples: use the stalker as the position for the camera with the player's position as it's target.

Swinger

The swinger acts like a ball on an elastic rope. It's practically a spring-system.

How does it work?

The whole library is structured using prototypal OOP. Instances of pointers can be created

// set up some drawing
var ctx = someSetupFunction();

// a manager needs to be created in order to use pointers
var pointerManager = new PointerManager();

function drawCircle(ctx, pointer) {
    ctx.beginPath();
    ctx.arc(pointer[0], pointer[1], 5, 0, 2 * Math.PI);
    ctx.closePath();
    ctx.color = "skyblue";
    ctx.fill();
}

var cursor = new Cursor();
cursor.onPositionChanged(function () {
    // the pointer can be accessed using `this`
    // do NOT reference the pointer by `cursor`, only use this!
    // this is important for mirrors/symmetries
    drawCircle(ctx, this);
});

Use wind in your project

Install wind using npm, npm install wind

wind's People

Watchers

James Cloos avatar Laura avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.