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

p5_gui

v1.0.6

Published

Experimental Graphical User Interface for P5js sketches

Downloads

22

Readme

p5_gui

Experimental Graphical User Interface for P5js sketches

  • Used for creating this SRT log viewer: https://djitelemetryoverlay.com

This was created for a specific project, so the interface and capabilities are very dependant on what was needed on that project. Hopefully it can be expanded and improved to fit other needs. Please let me know if you do something with it.

For it to work with P5js, your sketch should be in instance mode: https://github.com/processing/p5.js/wiki/Global-and-instance-mode

Installation

Using npm:

$ npm install p5_gui

Usage

//Load module
let gui = require('p5_gui');

//setup basic parameters
gui.setup(p,//p5js instance
  2,//shadow distance
  .5);//shadow alpha in HSB mode

//then we can start creating elements. Here we assume p is the p5js instance:
//Buttons and similar elements are drawn in CORNER mode, text alginment can be changed

//Area prints a rect where specified. Useful for backgrounds
gui.createArea("area_name",//element label
			0,//x position
			0,//y position
			600,//width
			600,//height
			p.color(100),//p5 color
			callback_function);//callback function

//Button
gui.createButton("button_name",//element label
			"Press me",//text value
			10,//x position
			10,//y position
			200,//width
			30,//height
			p.color(100,0,0),//p5 color
			callback_function,//callback function
			p.color(255));//textcolor

//Interactive slider
gui.createSlider("slider_name",//element label
		  10,//initial value (number)
			10,//x position
			50,//y position
			400,//width
			10,//height
			p.color(100,0,0),//p5 color
			callback_function,//callback function
			0,//minimum value
			20);//maximum value

//Toggle creates a button that can be either on or off
gui.createToggle("toggle_name",//element label
			true, //state, true or false
			"Press me",//label
			10,//x position
			100,//y position
			200,//width
			30,//height
			p.color(100,0,0),//p5 color
			callback_function,//callback function
			p.color(255);//text p5 color

//Radio creates several options in the form of buttons. Only one can be pressed
gui.createRadio("radio_name",//element label
			2, //initial value
			[1,2,3],//available values
			["One","Two","Three"],//labels
			10,//x position
			150,//y position
			500,//width
			30,//height
			p.color(100,0,0),//p5 color
			callback_function,//callback function
			p.color(255));//text p5 color

//Text just prints text
gui.createText("text_name",//element label
			"Text to display goes here",//initial value
			10,//x position
			200,//y position
			10,//height will determine text size
			p.color(0),//text p5 color
			callback_function,//callback function
			[p.CENTER,p.TOP],//TEXT ALIGN p5 values
			p.NORMAL);//text style p5

//To enable the drawing and interactivity of the elements, you should add the following methods to the usual p5 functions:

p.draw = function() {
  gui.mouseIsPressed(p.mouseIsPressed,p.mouseX,p.mouseY);
  gui.mouseOver(p.mouseX,p.mouseY);
  gui.draw();
  //your code
}

p.mousePressed = function() {
  gui.mousePressed(p.mouseX,p.mouseY);
  //your code
}

p.mouseReleased = function() {
  gui.mouseReleased();
  //your code
}

let gui_elements = gui.getGuiElts(); //returns the object to find elements by key

TODO

  • Simplify element creation?
  • Make interface clearer
  • parenting in gui elements???