Skip to content

Instantly share code, notes, and snippets.

View cbrewster's full-sized avatar

Connor Brewster cbrewster

View GitHub Profile
@mstange
mstange / main.mm
Created June 5, 2019 17:48
Example program that renders feTurbulence using OpenGL shaders
// Produces rendering that looks like http://tests.themasta.com/turbulence.svg
//
// Save to main.mm, and then compile and run using:
// $ clang++ main.mm -Wall -O3 -framework Cocoa -framework OpenGL -o test && ./test
//
// Equivalent SVG code:
//
// <svg xmlns="http://www.w3.org/2000/svg">
// <defs>
// <filter id="turb" color-interpolation-filters="sRGB">
@rust-play
rust-play / playground.rs
Created March 14, 2019 13:29
Code shared from the Rust Playground
enum Instruction {
Done,
LaserOn,
LaserOff,
Delay,
Coordinate(u8, u8),
}
impl Instruction {
pub fn hex(&self) -> String {
@rust-play
rust-play / playground.rs
Created December 20, 2018 03:49
Code shared from the Rust Playground
use std::fmt::Debug;
trait Widget: Debug {
fn create(self, builder: &mut RenderTreeBuilder) -> WidgetId;
}
#[derive(Copy, Clone, Debug)]
struct WidgetId(usize);
pub struct RenderTreeBuilder {
@rust-play
rust-play / playground.rs
Created November 14, 2018 23:19
Code shared from the Rust Playground
#[derive(Clone, Copy)]
pub struct NodeId(usize);
pub struct Node<T> {
data: T,
parent: Option<NodeId>,
}
pub struct Arena<T> {
nodes: Vec<Node<T>>,