This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Instruction { | |
Done, | |
LaserOn, | |
LaserOff, | |
Delay, | |
Coordinate(u8, u8), | |
} | |
impl Instruction { | |
pub fn hex(&self) -> String { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fmt::Debug; | |
trait Widget: Debug { | |
fn create(self, builder: &mut RenderTreeBuilder) -> WidgetId; | |
} | |
#[derive(Copy, Clone, Debug)] | |
struct WidgetId(usize); | |
pub struct RenderTreeBuilder { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Clone, Copy)] | |
pub struct NodeId(usize); | |
pub struct Node<T> { | |
data: T, | |
parent: Option<NodeId>, | |
} | |
pub struct Arena<T> { | |
nodes: Vec<Node<T>>, |