Skip to content

Instantly share code, notes, and snippets.

#####################################################################
# nDisplay config file
#
# This file demonstrates how to configure a simple powerwall based
# on 3 PCs. Each PC manages 2 output displays aligned vertically.
#
# Note:
# Before use, make sure all settings correspond to your system.
#####################################################################
var canvElt,
numFrames = 120,
duration = 3000,
recording = true,
time = 0
function setup() {
canvElt = createCanvas(600, 600).elt;
noStroke();
'use strict'
var gif, canvElt,
numFrames = 30,
duration = 1200,
recording = true,
time = 0
;
function setup() {
@gncgnc
gncgnc / grid-drop.js
Last active August 27, 2017 06:08
Code for grid-drop
var gif, canvElt,
numFrames = 45,
duration = 1500,
recording = true,
time = 0,
gridW = 10, // number of cells in a row/column
margin = 0.15,
pts = []
function MagneticField() {
this.mmts = []; // magnetic moments in the field
this.addmmt = function(mx,my,px,py) {
this.mmts.push({
m: new p5.Vector(mx,my), // the moment vector
pos: new p5.Vector(px,py) // its position in the field
})
}
@gncgnc
gncgnc / resizeNN.js
Last active June 7, 2023 01:52
Extends p5.Image to handle nearest neighbor resizing for scaling small images (e.g. pixel art) without blurring. You can also make regular images into pixelated images by shrinking then growing them with this method (a la MS Paint.)
/**
* Resize the image to a new width and height using nearest neigbor algorithm. To make the image scale
* proportionally, use 0 as the value for the wide or high parameter.
* For instance, to make the width of an image 150 pixels, and change
* the height using the same proportion, use resize(150, 0).
* Otherwise same usage as the regular resize().
*
* Note: Disproportionate resizing squashes the "pixels" from squares to rectangles.
* This works about 10 times slower than the regular resize. Any suggestions for performance increase are welcome.
*/
@gncgnc
gncgnc / getColorPalette.pde
Last active September 23, 2016 00:29
Getting random color palettes from an API, in Processing. Here's the API page: http://savemypalette.com/api/#random
color[] colors;
void getColorPalette(){
try {
String[] strs = loadStrings("http://savemypalette.com/api/random/palettes/");
saveStrings("colorData", strs);
JSONObject json = loadJSONObject("colorData");
JSONArray cs = json.getJSONArray("colors");