Skip to content

Instantly share code, notes, and snippets.

View nanjizal's full-sized avatar
💭
On the edge

nanjizal nanjizal

💭
On the edge
View GitHub Profile
@nanjizal
nanjizal / Main.hx
Last active November 25, 2016 00:38
CSS3 flexbox
package;
import js.Browser;
import js.html.StyleElement;
import js.html.DivElement;
import js.html.BodyElement;
import js.html.CSSStyleDeclaration;
class Main{
public static function main(){
var body: BodyElement = cast Browser.document.body;
var doc = js.Browser.window.document;
@nanjizal
nanjizal / Demo.hx
Last active January 2, 2017 03:34
Rough Heart for 'justTriangles'
package justTrianglesDemo;
import js.Browser;
import khaMath.Matrix4;
import justTrianglesDemo.WebGLDrawing;
import justTriangles.Triangle;
import justTriangles.Draw;
import justTriangles.Point;
import justTriangles.ShapePoints;
import htmlHelper.tools.CSSEnterFrame;
@:enum
@nanjizal
nanjizal / Demo.hx
Created January 4, 2017 06:52
Rough PathContext
package justTrianglesDemo;
import js.Browser;
import khaMath.Matrix4;
import justTrianglesDemo.WebGLDrawing;
import justTriangles.Triangle;
import justTriangles.Draw;
import justTriangles.Point;
import justTriangles.PathContext;
import justTriangles.ShapePoints;
import htmlHelper.tools.CSSEnterFrame;
#if poly2trihx
import org.poly2tri.SweepContext;
import org.poly2tri.Sweep;
//import org.poly2tri.Point;
#end
#if poly2trihx
var sweepContext = new SweepContext();
var sweep = new Sweep( sweepContext );
var p: Point;
public static var nearest = [10,12,14,15,16,18,20,21,24,25,28,30,32,35,36,40,42,48,50,56,60,64,70,72,75,80,84,90,100];
public static var divider = [5,6,7,3,8,6,5,7,6,5,7,5,8,7,6,8,7,6,5,7,6,8,7,6,5,8,7,6,5];
@nanjizal
nanjizal / Main.hx
Last active May 26, 2017 09:47
experimenting with xml -> json
@:enum
abstract OutType( Int ) {
var tagOut = 0;
var attOut = 1;
var contentOut = 2;
var nullOut = 4;
}
class Main { static public function main():Void { new Main(); }
public function new(){
trace( haxe.Resource.getString("sample") );
package;
import js.html.Float32Array;
import js.html.CanvasElement;
import js.html.webgl.RenderingContext;
import js.html.webgl.Program;
import js.html.webgl.Shader;
import js.html.webgl.Texture;
import js.html.webgl.Framebuffer;
import js.Browser;
import js.html.Uint16Array;
package;
import js.html.Float32Array;
import js.html.CanvasElement;
import js.html.webgl.RenderingContext;
import js.html.webgl.Program;
import js.html.webgl.Shader;
import js.html.webgl.Texture;
import js.html.webgl.Framebuffer;
import js.Browser;
import js.html.Uint16Array;
@nanjizal
nanjizal / Reset.hx
Created August 7, 2017 11:25
Reset
function reset( gl: RenderingContext ): RenderingContext {
var numAttribs = gl.getParameter( RenderingContext.MAX_VERTEX_ATTRIBS );
var tmp = gl.createBuffer();
gl.bindBuffer( RenderingContext.ARRAY_BUFFER, tmp );
for( ii in 0...numAttribs ){
gl.disableVertexAttribArray( ii );
gl.vertexAttribPointer(ii, 4, RenderingContext.FLOAT, false, 0, 0 );
gl.vertexAttrib1f( ii, 0 );
}
gl.deleteBuffer( tmp );
@nanjizal
nanjizal / approach.readme
Created January 17, 2018 17:29
Adding a Haxe target theory/approach
To add target to Haxe compiler, general theory.
1) Adjust main.ml and globals.ml with the language keyword as per example diffs.
2) Add a language folder to std folder, with subfolder _std Populate ideally with base Array etc.. implementations and add the haxe/ds and sys packages.
3) Add a gentarget.ml file to the generators folder that does the heavy work of converting haxe AST to target code.