Skip to content

Instantly share code, notes, and snippets.

View eeropic's full-sized avatar

Eero Pitkänen eeropic

View GitHub Profile
@eeropic
eeropic / index.html
Created February 12, 2018 20:04 — forked from MAKIO135/index.html
Using canvas as ThreeJS texture
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body style="background:#fff;">
<script src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r68/three.min.js"></script>
<canvas id="canvas"></canvas>
<script id="jsbin-javascript">
@eeropic
eeropic / paste-svg-from-clipboard-paper.js
Last active August 11, 2024 20:47
Paste SVG to Paper.js from clipboard
//CC2018
document.addEventListener('paste', function(evt) {
//Import SVG copied to clipboard from Illustrator
//remove last hidden character that will otherwise break the import
if(document.activeElement.nodeName!="TEXTAREA"){
var str=evt.clipboardData.getData('text/plain').slice(0, -1);
var svg=project.importSVG(str)
svg.clipped=false;
svg.children[0].remove()
svg.parent.insertChildren(svg.index,svg.removeChildren());
@eeropic
eeropic / pixijs-test.js
Created January 15, 2018 14:46
pixijs test
include('https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.5.1/pixi.min.js');
//const app = new PIXI.Application();
let app = new PIXI.Application({
width: 960,
height: 960,
antialias: true,
transparent: true,
resolution: 1
});
@eeropic
eeropic / tonejs-patch-graph.js
Last active January 22, 2018 21:27
tonejs patch / graph dev
include('https://cdnjs.cloudflare.com/ajax/libs/tone/0.12.7/Tone.min.js')
const DEBUG=0;
function log(item){if(typeof console != "undefined" && console.log && DEBUG){var props=[];for(var a in arguments){props.push(arguments[a])}console.log(props.join(","));}}
var nodeCount=0;
var edgeCount=0;
function omitKeys(key,value){
if (key=="Tone") return undefined;
@eeropic
eeropic / graph.json
Last active January 5, 2018 16:02
thinkin' about a graph format for tone.js
{
id:"Patch 1",
nodes:[
{
id:"Reverb 1",
type:"freeverb",
inlets:[
//min max here?
{id:"dryWet", type:"control"},
{id:"roomSize", type:"control"},
@eeropic
eeropic / Ae expressions and scripts.js
Last active June 12, 2024 10:23
After effects expressions and scripts collected from various authors and myself.
//dynamic parenting for 3d layers
//from Dan Ebberts on forums I think..
//Position
L=thisComp.layer("Object center");
L.toWorld(L.effect(name)("3D Point"));
//Scale
L =thisComp.layer("Object center");
[L.transform.scale[0]/100*value[0],L.transform.scale[1]/100*value[1],L.transform.scale[2]/100*value[2]];
@eeropic
eeropic / gifjs-test.js
Created January 1, 2018 18:23
GIF.js test
var gif = new GIF({
workers: 2,
quality: 10
});
gif.on('finished', function(blob) {
window.open(URL.createObjectURL(blob));
});
@eeropic
eeropic / paperjs-fx-stack.js
Created January 1, 2018 18:04
Paper.JS effect stack prototype
function roughenSegments(path,amp){
var amp=amp || 10;
for(s in path.segments){
var seg=path.segments[s];
seg.point.x+=Math.random()*(2-1)*amp
seg.point.y+=Math.random()*(2-1)*amp
}
}
Item.prototype.roughen = function (amp) {
@eeropic
eeropic / gist:0e2c96a38a451638b067e33efa12a0b5
Created December 17, 2017 11:26
svg graph editor draft 1
include('https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.3/svg.min.js');
$('.canvas').prepend('<div id="root"></div>')
document.addEventListener('contextmenu', event => event.preventDefault())
const DEBUG=true
function l(item) {if (typeof console != "undefined" && console.log && DEBUG) {var props=[];for(var a in arguments){props.push(arguments[a])}console.log(props.join(","))}}
var xOffset=$('.right_panel').offset().left
var yOffset=$('.right_panel').offset().top
function add(arr1,arr2){arr1.map(function (num, idx) {return num + arr2[idx]})}
function sub(arr1,arr2){arr1.map(function (num, idx) {return num - arr2[idx]})}
@eeropic
eeropic / paperjs-huewheel.js
Created December 9, 2017 12:03
paper.js color hue wheel
steps=128
radius=160
var wheel=new Group()
for(var i=0;i<steps;i++){
var seg=new Path();
var circum=radius*2*Math.PI
var step=circum/steps
seg.add([0,0],[radius,-step/2-0.5],[radius,step/2+0.5])