Skip to content

Instantly share code, notes, and snippets.

@kernalphage
kernalphage / TimedSequence.tsx
Created December 4, 2022 17:49
An example of how to stitch together Series.Sequences in Remotion
export const TimedSequence: React.FC<{ urls: string[]}> = ({ urls }) => {
const [allCues, setAllCues] = useState<>(undefined);
const [handle] = useState(() => delayRender());
const {fps} = useVideoConfig();
const fetchData = useCallback(async () => {
const all = await Promise.all(urls.map(async (url) =>
({url, durationInSeconds: await getAudioDurationInSeconds(url)})
import {_} from 'lodash';
export function makeEnum(arr){
let obj = {};
for (let val of arr){
obj[val] = Symbol(val);
}
return Object.freeze(obj);
}
@kernalphage
kernalphage / hatching.pyde
Last active March 2, 2018 06:12
crosshatching in processing
def TriSign(a,b,c):
return (a.x - c.x) * (b.y- c.y) - (a.y-c.y) * (b.x-c.x)
class pLine:
def __init__(self, x1,y1,x2,y2):
self.a = PVector(x1,y1)
self.b = PVector(x2,y2)
def pnorm(self):
ret = (self.a - self.b)
@kernalphage
kernalphage / Artsy_Turbulence.pde
Created June 15, 2017 23:49
Art generator written in Processing
/**
* Simple Turbulence + art
* By Matt Dobler
*/
int _w = 1920;
int _h = 1080;
PVector dim = new PVector(_w, _h);
PVector box;
@kernalphage
kernalphage / rotational_for.js
Last active August 15, 2016 03:29
some hexagons spinning around for your pleasure. Works with P5js
//rendered gif can be found at https://imgur.com/gallery/uADuMZE/
//a rotational for each loop, Runs fn() Spokes times, evenly spaced along a circle len width
//supports fractional spokes for 'unfolding'
function rotational_for(spokes, len, fn) {
var di = TAU / spokes;
for (var i = 0; i < spokes; i++) {
push();
angle =i*di
translate(sin(angle)*len, cos(angle)*len, 0);
@kernalphage
kernalphage / imageParse.py
Created February 22, 2016 04:29
given an image, generates a palette of n colors
import collections
from functools import *
import argparse
from PIL import Image
from colour import Color
def interesting_colors(filename, num_colors, steps=32, sample_scale=(200, 200)):
"""
using UnityEngine;
using UnityEditor;
using System.Collections;
public class SpoopyEditor : EditorWindow {
static float hauntTime = 0;
static float hauntSpeed = .005f;
static bool haunting = false;
public Texture2D skeletons = (Texture2D) Resources.Load("spook/ghost.jpg", typeof(Texture2D));
using UnityEngine;
using System.Collections;
public class _C {
/* Screen to world utils */
public static Vector2 ScreenBottomLeft()
{
Vector2 dim = new Vector3(0,0,Camera.main.farClipPlane);
return Camera.main.ViewportToWorldPoint(dim);
return dim;