Skip to content

Instantly share code, notes, and snippets.

export default class EventEmitter
{
constructor()
{
this.callbacks = {}
this.callbacks.base = {}
}
on(_names, callback)
{
@bonsak
bonsak / RGB-HSV conversions.fsh
Created December 30, 2023 10:37 — forked from Aeldrion/RGB-HSV conversions.fsh
GLSL functions for HSV to RGB and RGB to HSV conversion
vec3 hsv_to_rgb(vec3 color) {
// Translates HSV color to RGB color
// H: 0.0 - 360.0, S: 0.0 - 100.0, V: 0.0 - 100.0
// R, G, B: 0.0 - 1.0
float hue = color.x;
float saturation = color.y;
float value = color.z;
float c = (value/100) * (saturation/100);
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@bonsak
bonsak / AE_to_Houdini.py
Created February 22, 2019 09:11 — forked from howiemnet/AE_to_Houdini.py
First attempt at getting AE camera data into Houdini (hacky woo)
# Ultra quick'n'hacky AE camera animation importer for Houdini.
# Create a new shelf, create a new tool, paste this into the script box.
#
# In AE, select the Orientation and/or Position keyframes, and Ctrl/Cmd-C them to the clipboard
# Open a new text file (Notepad or Textedit) and paste the clipboard contents in. There's your keyframes.
# Save the text file somewhere and amend the filename line below to suit
# In Houdini, create a camera (it's up to you to set the same zoom / aperture as the AE one).
# ... and run this script (well, press the shelf button you stuck this on)
@bonsak
bonsak / Houdini - copy camera animation data to clipboard.py
Created February 22, 2019 09:11 — forked from howiemnet/Houdini - copy camera animation data to clipboard.py
Houdini to AE camera animation clipboard exporter (now with Zoom! Woo!)
# Houdini to After Effects camera animation exporter
# This version: 7/11/2018, by Howard Matthews - [email protected]
# Copyright: CC-0 - use and abuse. Please pass on the knowledge.
# Note: there's no error-checking in this script, but it alters nothing within the Houdini scene, so it'll just
# fail with an error if you try running it without a camera selected. No harm done.
import hou
theNodes = hou.selectedNodes()
#This python script will start AE and run a jsx file in Documents when AE has started.
import subprocess, sys
app = 'C:/Program Files/Adobe/Adobe After Effects CC 2018/Support Files/AfterFX.exe'
subprocess.Popen([app, '-s', "var a = new File('C:/Users/bonsak/Documents/test.jsx'); a.open(); eval(a.read()); app.exitAfterLaunchAndEval = false;"])
// Run in a detail wrangle. Added .h to get syntax highlighting
i[]@index;
int rand;
vector newpos;
int succ;
// create a simple ordered array
for (int i=0; i<@numpt;i++){
@index[i] = i;
}
import hou
rop = hou.node("/obj").createNode("matnet", "Materials")
mat = hou.node("/obj").createNode("ropnet", "Render")
shad = hou.node("/obj/Materials").createNode("redshift::Material", "Material").setMaterialFlag(True)
rop.moveToGoodPosition()
mat.moveToGoodPosition()
@bonsak
bonsak / Edge_Kernel.vex
Created June 29, 2016 15:23
Edge_Kernel.vex
int closept[] = pcfind(0, "Cd", @Cd, 0.1, 9);
vector kernelsum = 0;
vector firstcol = point(0, "Cd", closept[0]);
for (int i = 1; i < 9; i++){
vector closecol = point(0, "Cd", closept[i]);
kernelsum += ( closecol * -1 );
}
f@density = length( kernelsum += ( firstcol * 8 ) );
<?php
remove_action( 'rest_api_init', 'create_initial_rest_routes', 0 );