Skip to content

netizenorg/netnet-standard-library

Repository files navigation

nn ( ◕ ◞ ◕ ) netnet-standard-library

nn (netnet-standard-library.js) is a browser-based JavaScript library designed to aid creative coders working on internet art and web design projects. It serves as the core utility library for netnet.studio, functioning both as a tool-kit for creating interactive and generative work within the platform and as a tool for building netnet.studio itself. The library is intentionally approachable for beginners, featuring helpful error messages and friendly documentation, yet expressive enough to support complex creative work.

introduction page documentation page demo gallery

getting started

Add a single <script> tag to your HTML, there's no build step, no package manager, no dependencies. The global nn object is then available everywhere on the page. Pin to a specific version so your project won't change unexpectedly if the library updates:

<!-- 1.0.1 (most recent stable version) -->
<script src="https://cdn.jsdelivr.net/gh/netizenorg/netnet-standard-library@1.0.1/build/nn.min.js"></script>

<!-- 0.9.0 (the original pre-release version) -->
<script src="https://cdn.jsdelivr.net/gh/netizenorg/netnet-standard-library@0.9.0/build/nn.min.js"></script>

Here's a "hello world" GIF-drawing tool, you can also remix this on netnet.studio.

<script src="https://cdn.jsdelivr.net/gh/netizenorg/netnet-standard-library/build/nn.min.js"></script>
<script>
  function drawGifs () {
    // if mouse is not (!) pressed down exit function
    if (!nn.mouseDown) return
    // otherwise, create a new gif
    nn.create('img')
      .set('src', 'https://netnet.studio/cd.gif')
      .positionOrigin('center')
      .position(nn.mouseX, nn.mouseY)
      .css('pointer-events', 'none')
      .addTo('body')
  }

  // click and drag mouse across the screen
  // to draw new gif img elements
  nn.on('mousemove', drawGifs)
</script>

To learn more visit our introduction page, there you'll find intros to the library's core concepts/patterns including:

There are many amazing creative coding libraries that extend the capabilities of the Web's creative APIs, often providing frameworks for expressing higher-level concepts, like how A-Frame's Entity-Component-System adds game design principles to WebGL and WebXR, or how Tone.js brings music synthesis and DAW (Digital Audio Workstation) concepts to the Web Audio API. While the nn library can be used on its own, it's really designed to work alongside these other frameworks. For example, you could use D3.js to generate data visualizations, then apply nn's color theory methods to ensure the chart colors follow harmonious color schemes and meet WCAG AA accessibility standards. Similarly, you could use nn's music theory utilities to generate scales and chords, then pass them to Tone.js for playback. You can see this in action in our demos gallery.

contributions

If you'd like to contribute to this repository, below are the steps you should take to setup a local project as well as contribute any bug fixes, additions or other changes.

setup

  1. start by fork our repo this repo
  2. then clone your fork git clone https://github.com/[YOUR_USER_NAME]/netnet.studio.git
  3. then install the dev dependencies npm install
  4. lastly, setup a remote "upstream" to our repo: git remote add upstream https://github.com/netizenorg/netnet-standard-library.git

development

  1. before starting on a new feature it's always a good idea to run git pull upstream main to pull updates from our repo.

  2. create a "feature" branch git checkout -b [FEATURE-NAME] for your contribution.

  3. All the source code can be found in /src, there you'll find sub-folders for the different categories, within those sub-folders you'll find the source code files and their accompanying documentation files.

  • If you edit or add a new function/method, make sure to add/edit it's documentation entry as well.
  • If your contribution also requires updating the API Index (in this README below) make sure to do that as well
  1. as you work locally you can
  • use the npm run build command to create new builds of the library
  • serve the repo locally to use the /examples page to write examples and test your changes
  • use the npm run lint command to ensure you're conforming to our coding style before making any commits.
  • use the npm run docs to make sure the source property of your doc entry has the right start/end lines
  1. when you're ready, create a PR from your feature branch and into our main branch.

  2. Once your PR has been merged, clean things up before starting on another feature

git checkout main
git pull upstream main
git push origin --delete [FEATURE-NAME]
git branch --delete [FEATURE-NAME]

API Index

Below is an index of all of nn internal methods with hyperlinks to their documentation. You can also find the full documentation page here: https://netizenorg.github.io/netnet-standard-library/docs/

properties

core utilities

rendering (html)

media utilities

user permissions

data

feature detection

Maths

Color Theory

Music Theory

rendering (canvas)

nn.create('canvas') returns a canvas element with additional drawing methods:

style properties

drawing

custom paths

transforms

utilities

rendering (svg)

nn.create('svg') returns an SVG element with shape factory methods. Shapes returned by those factories are themselves chainable.

shape factory methods

layout (chainable on any SVG shape)

  • .position(x, y) // move element; meaning depends on type (cx/cy, x/y, or translate)
  • .positionOrigin(type) // 'center' makes .position() center rects and text on the given point
  • .size(...) // resize: circle→r, ellipse→rx,ry, rect/svg→width,height

styling (chainable on any SVG element)

transforms (chainable on any SVG element)

( ◕ ◞ ◕ )

About

a browser-based JavaScript library designed to aid creative coders working on internet art and web design projects. central part of netnet.studio

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors