This file contains 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
func drawText(s: String, w: CGFloat, h: CGFloat, colour:CGColor) -> CGImageRef { | |
let bounds = CGRectMake(0, 0, w, h) | |
// Create the bitmap-backed CoreGraphics contexts | |
let context = CGBitmapContextCreate(nil, Int(w), Int(h), 8, 0, | |
CGColorSpaceCreateDeviceRGB(), | |
CGImageAlphaInfo.PremultipliedFirst.rawValue | CGBitmapInfo.ByteOrder32Little.rawValue) | |
CGContextSetFillColorWithColor(context, colour) | |
CGContextFillRect(context, bounds) |
This file contains 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
/// <summary> | |
/// Allows us to use enum values as a data source; e.g. for providing as an ItemsSource | |
/// on a combo box control for user selection. | |
/// </summary> | |
public class EnumItemsSource : Collection<String>, IValueConverter | |
{ | |
Type _type; | |
IDictionary<Object, Object> _valueToNameMap; | |
IDictionary<Object, Object> _nameToValueMap; |
This file contains 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
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>D3 and Knockout</title> | |
<script src="knockout-2.2.1.js"></script> | |
<script src="lib/d3.v2.js"></script> | |
<link rel="stylesheet" href="src/nv.d3.css" type="text/css"/> | |
<script> | |
var nrects = 1; | |
function Rect() { |
This file contains 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
#define MAX_BALLS 10 | |
precision mediump float; | |
varying lowp vec2 v_texCoord; | |
uniform float u_width; | |
uniform int numballs; | |
uniform vec3 balls[MAX_BALLS]; //.xy is position .z is radius | |
float energyField(in vec2 p, in float iso) |
This file contains 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
open System | |
/// Given a starting location, and functions for determining possible | |
/// moves and whether we're reached the goal. | |
/// Returns a tuple of boolean and a list of locations in the path | |
/// to the goal. | |
let tryFindPath (start : 'T) (neighbours : 'T -> 'T []) (isGoal : 'T -> bool) = | |
let rec tryPath l visited = | |
if isGoal l | |
then |