Skip to content

a collection of other netizen utility libs primarily for use within netnet.studio projects

License

Notifications You must be signed in to change notification settings

netizenorg/netnet-standard-library

Repository files navigation

netnet-standard-library

nn (netnet-standard-library.js) is a browser based JavaScript library designed to aid creative coders (artists, designers, etc), it's a core utility library used within netnet.studio; both in the sense that it can be used to create sketches in netnet, but also that it's used to create netet.studio itself. It can also be used outside of netnet.studio as you would any other typical JavaScript library (with some exceptions, see note below).

There are loads of amazing creative coding libraries out there (p5.js, three.js, tone.js, A-Frame, hydra.js, D3.js, Paper.js, GSAP, etc) which extend the capabilities of the Web's creative APIs and often provide a framework for expressing higher level concepts (the way A-Frame's Entity-Component-System adds game design principles to the WebGL and WebXR APIs or the way Tone.js adds music theory to the WebAudio API). Unlike these libraries, nn doesn't extend or abstract the Web's more creative APIs, instead it has a much more modest goal of expanding on JavaScript's standard library (like it's Math object) as well as some of the Web's core APIs (like window and navigator), in this way that might be useful for artists. It's more of a utility library than it is a creative framework.

This repo consists of a number of git "sub-modules", namely Averigua.js, Maths.js, Color.js and FileUploader.js, all of which can be used independently. This repo simply packages them up in one place, provides thorough documentation and adds a few more properties and methods specifically for aiding beginners embarking on their creative coding journey on netnet.studio.

using the library

CDN

You can use the library by importing it with a <script> linking to a CDN like this:

<script src="https://cdn.jsdelivr.net/gh/netizenorg/netnet-standard-library/build/nn.min.js"></script>

download locally

If you prefer to download a copy locally, you can download the just minified library here and include it in your local project.

Or use npm:

npm install git+https://github.com/netizenorg/netnet-standard-library.git

NPM will of course download much more than you need (the entire project).

You can also use this library directly on netnet.studio by simply including a script tag in your sketch. Check out this example on netnet.studio. NOTE: that will only work in a "sketch", if you are working on a "project" on netnet, make sure to either include a copy of the library in your repo or use the link to the CDN above.

setup

<!-- import the library -->
<script src="https://cdn.jsdelivr.net/gh/netizenorg/netnet-standard-library/build/nn.min.js"></script>
<script>
  /* global nn */

  // a function which uses the library's randomColor()
  // method to change the page's background color
  function changeBGColor () {
    nn.get('body')
      .css({
        background: nn.randomColor()
      })
  }

  // change the background color when the page loads
  nn.on('load', changeBGColor)
  // change background color when the page is clicked
  nn.on('click', changeBGColor)
</script>

examples

For more examples demonstrating how this library can be used checkout the examples doc

API / documentation

properties (internal variables)

methods (internal functions)

  • nn.on() // register an event listener on the window
  • nn.create() // creates an "overloaded" HTMLElement
  • nn.get() // selects an element on the page and returns an "overloaded" one
  • nn.getAll() // selects all matching elements and returns"overloaded" ones
  • nn.loadImage() // a Promised based approach for loading images
  • nn.modifyPixels() // method for processing/filtering images
  • nn.askForStream() // ask user permission to use their mic/camera
  • nn.askForGPS() // ask user permission for location data
  • nn.MIDI() // access any plugged in MIDI devices
  • nn.fetch() // a version of fetch() which gets around CORS issues

Function for binding CSS variables to interactions with HTML elements (input, buttons, etc)

Functions for working with data, specifically designed for JSON or CSV data:

Functions for detecting useful information about your visitor's device. These come from the Averigua.js sub-module.

Other useful math functions often used in creative coding projects which are not included in JavaScript's built in Math object. These come from the Maths.js sub-module.

Functions for doing various color maths. These come from the Color.js sub-module.

classes

contributions

If you'd like to contribute to this repository, our contributors doc include steps you should take to setup a local project as well as contribute any bug fixes, additions or other changes.

About

a collection of other netizen utility libs primarily for use within netnet.studio projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published