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
class JQ | |
{ | |
static public inline function select(j:js.Dom.HtmlDom):js.JQuery | |
{ | |
return new js.JQuery(j); | |
} | |
static public inline function query(j:String):js.JQuery | |
{ | |
return new js.JQuery(j); |
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
class Main { | |
static function main() { | |
MyMacro.testReify(); | |
} | |
} |
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
import haxe.macro.Expr; | |
class FTW | |
{ | |
public static function build() | |
{ | |
return haxe.macro.Context.getBuildFields().map(transformField); | |
} | |
static function transformField(field:Field) |
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
// Modified version of a tilt shift shader from Martin Jonasson (http://grapefrukt.com/) | |
// Read http://notes.underscorediscovery.com/ for context on shaders and this file | |
// License : MIT | |
uniform sampler2D tex0; | |
varying vec2 tcoord; | |
varying vec4 color; | |
/* | |
Take note that blurring in a single pass (the two for loops below) is more expensive than separating |
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
class Metric { | |
static function main() { | |
var coinRadius:Millimeters = 12; | |
var myHeight:Centimeters = 180; | |
var raceLength:Meters = 200; | |
var commuteDistance:Kilometers = 23; | |
diff( coinRadius, myHeight ); // 1.788 meters | |
diff( raceLength, commuteDistance ); // 22800 meters | |
sum( commuteDistance, coinRadius ); // 23000.012 meters |
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
//Rotate the camera such that z points up and x to the right | |
var o:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(-90, 0, 0).radians()); | |
//Rotate by Arctan(sin(45°)) (grabbed from wikipedia) around x, to get the top-down part | |
var q:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(Math.atan(Math.sin(45 * Maths.DEG2RAD)), 0, 0)); | |
//Rotate around z by -45° to get the side-on part | |
var p:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(0, 0, -45).radians()); | |
//Combine the rotations and apply to the camera |
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
package com.blazingmammothgames.util; | |
#if neko | |
import neko.vm.Thread; | |
import neko.vm.Mutex; | |
#elseif cpp | |
import cpp.vm.Thread; | |
import cpp.vm.Mutex; | |
#end |
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
package ; | |
import haxe.ds.StringMap; | |
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
import haxe.macro.Printer; | |
import haxe.macro.Type.ClassType; | |
import neko.Lib; | |
using haxe.macro.ExprTools; |
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
import haxe.ds.Either; | |
abstract OneOf<A, B>(Either<A, B>) from Either<A, B> to Either<A, B> { | |
@:from inline static function fromA<A, B>(a:A) : OneOf<A, B> return Left(a); | |
@:from inline static function fromB<A, B>(b:B) : OneOf<A, B> return Right(b); | |
@:to inline function toA():Null<A> return switch(this) {case Left(a): a; default: null;} | |
@:to inline function toB():Null<B> return switch(this) {case Right(b): b; default: null;} | |
} |
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
/** | |
* @author Mark Knol | |
*/ | |
class MacroJsonValidator { | |
public static macro function validateJson(path:String) { | |
if (sys.FileSystem.exists(path)) { | |
var content = sys.io.File.getContent(path); | |
try { | |
// Test the json by parsing it. | |
// It will throw an error when you made a mistake. |
OlderNewer