Skip to content

Instantly share code, notes, and snippets.

View eeropic's full-sized avatar

Eero Pitkänen eeropic

View GitHub Profile
//https://github.com/jkroso/parse-svg-path
var cmdLength = {a:7, c:6, h:1, l:2, m:2, q:4, s:4, t:2, v:1, z:0}
var segPattern = /([astvzqmhlc])([^astvzqmhlc]*)/ig
var numPattern = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig
function parseVals(args) {
var nums = args.match(numPattern)
return nums ? nums.map(Number) : []
}
@eeropic
eeropic / catmullRomPaper.js
Created July 11, 2019 19:42
catmull rom test
//from https://qroph.github.io/2018/07/30/smooth-paths-using-catmull-rom-splines.html
function getCurve(points,tension,alpha,closed) {
_tension = tension || 0;
_alpha = alpha || 0.5;
_closed = closed || false;
_points = points || [];
const dist = (p0, p1) => {
return Math.sqrt(Math.pow(p1.x - p0.x, 2) + Math.pow(p1.y - p0.y, 2));
@eeropic
eeropic / traverse.js
Created July 26, 2019 20:59
recursive depth-first object traversal for lottie json
// modified from derick bailey https://derickbailey.com/2015/07/19/using-es6-generators-to-recursively-traverse-a-nested-data-structure/
function getType(object) {
return Object.prototype.toString.call(object)
.match(/^\[object\s(.*)\]$/)[1].toLowerCase()
}
function isArray(o) {
return getType(o) === 'array';
}
@eeropic
eeropic / ableton-push-1-lcd-characters-0-127.txt
Last active July 6, 2021 06:02
Ableton Push 1 lcd text symbols
In rows of 16 chars
ascii 0-127
↑↓≡◧◨■◫❏¦°ÄÇÖÜßà
äçèéêîñö÷øüь…█←→
!"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
@eeropic
eeropic / pd-paper.js
Last active September 16, 2019 22:28
minimal pd parser -> paper.js
var str=`#N canvas 654 312 778 598 12;
#X obj 70 130 midiin 1, f 38;
#X floatatom 140 250 5 0 0 0 - - -;
#X symbolatom 70 190 10 0 0 0 - - -;
#X obj 30 130 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 140 280 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 170 280 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10
-262144 -1 -1 0 256;
@eeropic
eeropic / pd-regex.txt
Last active September 16, 2019 22:55
pd patch parsing regex WIP
(#.) (\w*) (\d*) (\d*) (\S*) (\S*) (\S*) ?(\S*)?
@eeropic
eeropic / nestedproxy.js
Created September 25, 2019 18:42
nested object proxy handler from Michał Perłakowski & James Coyle at https://stackoverflow.com/questions/41299642/how-to-use-javascript-proxy-for-nested-objects
const handler = {
get(target, key) {
if (key == 'isProxy')
return true;
const prop = target[key];
if (typeof prop == 'undefined')
return;
if (!prop.isProxy && typeof prop === 'object')
target[key] = new Proxy(prop, handler);
@eeropic
eeropic / _testTool.svg
Last active January 22, 2020 20:28
svg test papertool #papertool .js source in the 2nd file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file has been truncated, but you can view the full file.
testData = [[-0.002345,0.049722,-0.006237,180,120,95],
[-0.002345,0.049744,-0.006316,180,120,95],
[-0.002397,0.049722,-0.006316,180,120,95],
[-0.002488,0.049722,-0.007304,183,122,97],
[-0.002345,0.049773,-0.007304,183,122,97],
[-0.002345,0.049722,-0.007538,183,122,97],
[-0.001620,0.049722,-0.005327,189,127,101],
[-0.001356,0.049722,-0.004959,189,127,101],
[-0.001356,0.049826,-0.005327,189,127,101],
[-0.001356,0.050038,-0.006316,192,129,103],
@eeropic
eeropic / gzip.js
Last active June 10, 2021 14:41
gzip-js
// https://github.com/beatgammit/gzip-js/blob/master/lib/gzip.js
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
const gzip = require('gzip-js');
},{"gzip-js":6}],2:[function(require,module,exports){
(function () {
'use strict';
var table = [],
poly = 0xEDB88320; // reverse polynomial