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
package; | |
/** | |
* Mostly stolen from http://www.codeproject.com/Articles/20435/Using-C-To-Generate-ASCII-Art-From-An-Image | |
* @author Andreas Rønning | |
*/ | |
private typedef BMD = { | |
function getPixel(x:Int, y:Int):Int; | |
var width(default, never):Int; | |
var height(default, never):Int; |
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
using Unpack; | |
class Main { | |
static function main() { | |
f().unpackInto( [ v1, { a: { length: v2 } }, { a: [ v3, _, v4 ] } ] ); | |
trace(v1); // { a: [ 1 ] } | |
trace(v2); // 2 | |
trace(v3); // 4 | |
trace(v4); // 5 |
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
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
class EnumAbstractMacro | |
{ | |
public static function build():Array<Field> | |
{ | |
var fields = Context.getBuildFields(); | |
var values = []; |
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
class Main { | |
var arg1:Int; | |
var arg2:String; | |
var arg3:Bool; | |
function new(arg1 = 0, arg2 = "foo", arg3 = false) { | |
MyMacro.initLocals(); | |
} | |
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
Needed a function would spiral out to cover a tiled world, then remembered these posts by John Carmack: | |
* https://twitter.com/ID_AA_Carmack/status/308678512099852288 | |
* https://twitter.com/ID_AA_Carmack/status/308676302079160320 | |
Derived the solution with an initial implementation that uses several arrays to calculate positions, | |
then removed those array values for a more compact implementation. There's probably still room for | |
improvement, though. | |
It uses uniform initialisation from c++11, so you'll have to enable compiler support for it if you want |
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
typedef struct FontHeader { | |
int32_t fVersion; | |
uint16_t fNumTables; | |
uint16_t fSearchRange; | |
uint16_t fEntrySelector; | |
uint16_t fRangeShift; | |
}FontHeader; | |
typedef struct TableEntry { | |
uint32_t fTag; |