Skip to content

Instantly share code, notes, and snippets.

View polyclick's full-sized avatar
👽
I see the matrix

polyclick polyclick

👽
I see the matrix
View GitHub Profile
float timeDiff = ofGetElapsedTimef() - lastPitchChangeTime;
if(roundedCurrPitch != roundedPrevPitch && pitchConfidence > minimumConf && timeDiff > pitchRelease) {
// first, send [off note] for previous note
midiOut.sendNoteOff(channel, roundedPrevPitch);
// send current note value over midi
// scale the ascii values to midi velocity range 0-127
// see an ascii table: http://www.asciitable.com/
var http = require('http')
var fs = require('fs')
var socket = require('socket.io')
var midi = require('midi')
var app = http.createServer()
var io = socket(app)
app.listen(5000)
// difference between current and previous cursor position & distance
this.delta = pk.Vector.sub(this.lerped, this.plerped)
this.distance = this.delta.mag()
// paint repeatedly by interpolating the bristle’s stamp position over the course of distance
// then stamp the bristles texture onto the final render target by copying its pixels
let numDraws = this.distance || 1
for (let i = 0; i < numDraws; i++) {
let ipos = pk.Vector.lerp(this.plerped, this.lerped, i / numDraws)
this.bristles.position = new PIXI.Point(ipos.x, ipos.y)
@polyclick
polyclick / background-cover.frag
Created February 20, 2019 12:24
map uv coordinates to do a background-position: cover in screen space
vec2 backgroundCoverUV(vec2 uv, vec2 resolution, vec2 texResolution) {
vec2 s = resolution;
vec2 i = texResolution;
float rs = s.x / s.y;
float ri = i.x / i.y;
vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);
vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;
return uv * s / new + offset;
}
@polyclick
polyclick / _1_scraping.js
Last active April 16, 2022 07:44
Scraping & reading Versum pixel data
// Fetches minted tokens from Versum, starting from the most recent -> older
//
// You can try this out in a REST app or curl'ing by calling a GET to
// https://versum.xyz/api/public/feed?offset=0&limit=10&maxtime=1649840640000
// Returns a json object with the token data, creator wallet & info, and urls to the images on IPFS
// Use query string params 'offset' and 'limit' to paginate data
//...