Skip to content

Instantly share code, notes, and snippets.

import java.security.*;
import java.util.*;
static class Utils {
static void saveImage(PApplet applet) {
int i = 0;
File file = null;
String fileName = null;
do {
i++;
@troughton
troughton / swiftbuild
Last active April 13, 2016 05:06
Swift Build Script
swiftc --driver-mode=swift -lPackageDescription Package.swift -fileno 3
swiftc --driver-mode=swift -lPackageDescription Packages/SGLOpenGL-2.0.2/Package.swift -fileno 4
swiftc --driver-mode=swift -lPackageDescription Packages/CGLFW3-1.0.0/Package.swift -fileno 4
swift-build-tool -f .build/debug.yaml default -v
swiftc -Xlinker -LPackages/CGLFW3-1.0.0 -g -L.build/debug -o .build/debug/SwiftGLTest -emit-executable .build/debug/SwiftGLTest.build/main.swift.o .build/debug/SGLOpenGL.build/Commands.swift.o .build/debug/SGLOpenGL.build/Constants.swift.o .build/debug/SGLOpenGL.build/Loaders.swift.o .build/debug/SGLOpenGL.build/SwiftGL.swift.o
@troughton
troughton / .block
Last active October 6, 2016 03:52 — forked from dribnet/.block
Parameterised Cartoon Faces
license: mit
@troughton
troughton / .block
Last active October 6, 2016 03:52 — forked from dribnet/.block
Feral – A Parametric Font
license: mit
@troughton
troughton / .block
Last active October 11, 2016 03:29 — forked from dribnet/.block
Painterly Weatherbot
license: mit
@troughton
troughton / .block
Last active October 6, 2016 03:47 — forked from dribnet/.block
Dimensional Glyph
license: mit
@troughton
troughton / .purview_helper.js
Last active October 24, 2016 23:52 — forked from dribnet/gist:a0ef81cf281d53066ebb2416c1cae3b4
MDDN 342 Final Project
// note: this file is poorly named - it can generally be ignored.
// helper functions below for supporting blocks/purview
function saveBlocksImages(doZoom) {
if(doZoom == null) {
doZoom = false;
}
// generate 960x500 preview.jpg of entire canvas
@troughton
troughton / ExtrudeAlongCurve.py
Created March 9, 2017 06:40
Maya script to extrude along a curve.
import maya.cmds as cmds
import math
import numpy
def basisToEuler(tangent, bitangent, normal):
#Adapted from http://www.staff.city.ac.uk/~sbbh653/publications/euler.pdf
m = [tangent, bitangent, normal]
if abs(m[2][0]) != 1:
theta = -math.asin(m[2][0])
@troughton
troughton / swift-windows-crosscompile-instrs.md
Last active April 5, 2019 15:15
Swift Cross-Compilation on Windows 10

Cross-compiling Swift for Windows through the Linux Subsystem for Windows

This tutorial will walk you through the process of compiling your own native programs for Windows using the Ubuntu on Windows. While the development environment and Swift compiler used here will be the standard toolchain for Linux, you'll also be able to cross-compile programs that run natively on Windows like any other executable.

Required Environment

This tutorial assumes a computer running an up-to-date 64-bit version of Windows 10 (at the time of writing, the Fall Creators' Update was the most recent build).

You'll also need Visual Studio 2017; the Community Edition is sufficient, since we'll only be using the SDKs that come with it and some command line tools.

@troughton
troughton / AmbientDice.cpp
Last active April 23, 2020 14:32
Ambient Dice
struct Vertex {
vec3 value;
vec3 directionalDerivativeU;
vec3 directionalDerivativeV;
};
void AmbientDice::hybridCubicBezierWeights(u32 i0, u32 i1, u32 i2, float b0, float b1, float b2, VertexWeights *w0Out, VertexWeights *w1Out, VertexWeights *w2Out) const {
const float alpha = 0.5f * sqrt(0.5f * (5.0f + sqrt(5.0f))); // 0.9510565163
const float beta = -0.5f * sqrt(0.1f * (5.0f + sqrt(5.0f))); // -0.4253254042