Git Product home page Git Product logo

bndr-js's Introduction

Bndr.js

🖱️ ⌇ ⌨️ ⌇ 🎹 ⌇ 🎮 ⌇ 🖊️ ⌇ 👆

DemoAPIBecome a Sponsor

npm version npm licence

Bndr.js /ˈbaɪndɚ/ is a library designed to compose events from various user inputs and chain filters in a monadic manner, integrating them into a single event object. It accommodates input devices such as mice🖱️, styluses🖊️, touch inputs👆, keyboards⌨️, MIDI controllers🎹, and gamepads🎮. Developed and maintained by Baku Hashimoto.

Potential use cases for this library include:

  • Associating user inputs with arbitrary triggers for VJing
  • Introducing manual operations in generative art.

To get a feel for how it works, please try out this demo.

Supported Parameters

  • Pointer (mouse, stylus, touch)
    • All parameters supported in PointerEvent. (pressure, tilt, multi-touch)
  • MIDI
    • CC and velocity
  • Gamepad
    • Vendor-specific button name support: JoyCon, PS5 Controller

How to use

Installation

npm install bndr-js

Example

import {Bndr} from 'bndr-js'

Bndr.pointer(window).on(pressed =>
	console.log('Pointer %s', pressed ? 'pressed' : 'released')
)

Bndr.pointer(window)
	.position()
	.lerp(vec2.lerp, 0.1)
	.on(([x, y]) => console.log('Pointer moved: [%f, %f]', x, y))

Bndr.keyboard(window)
	.keydown('shift+c')
	.on(() => console.log('Hotkey shift+c pressed'))

Bndr.midi()
	.note(0, 50)
	.on(velocity => console.log('MIDI slider #50 moved: %d', velocity))

Bndr.gamepad()
	.axis(0)
	.on(([x, y]) => console.log('Gamepad axis #0 tilted: [%f, %f]', x, y))

License

This repository is published under an MIT License. See the included LICENSE file.

bndr-js's People

Contributors

baku89 avatar charliewilco avatar nick-w-nick 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.