Skip to content

Instantly share code, notes, and snippets.

View markknol's full-sized avatar
🧪
Doodling around

Mark Knol markknol

🧪
Doodling around
View GitHub Profile
@markknol
markknol / Main.hx
Created September 21, 2018 13:30
Rainbow colors
function getRainbow(size:Int) {
inline function sinToHex(i, phase) {
var sin = Math.sin(Math.PI / size * 2 * i + phase);
var int = Math.floor(sin * 127) + 128;
return StringTools.hex(int, 2);
}
return [for (i in 0...size) {
var red = sinToHex(i, 0 * Math.PI * 2/3);
var blue = sinToHex(i, 1 * Math.PI * 2/3);
var green = sinToHex(i, 2 * Math.PI * 2/3);
@markknol
markknol / Publish to Haxelib using Travis.md
Last active July 17, 2018 20:06
Publish to Haxelib (using Travis) using Github Releases

Publish to Haxelib using Travis using Github Releases

This tutorial will help you publish your library automatically to lib.haxe.org when you create a release on GitHub.

Motivation

  • Collaborators on GitHub can help publish on haxelib without the need of sharing/knowing your password.
  • It automatically tests your project, this ensures you don't publish broken builds.
  • It makes sure you have tagged your projects because that's what GitHub does for you when doing a release.
  • It is more transparent for collaborators/users what goes into the haxelib package zip file.
@markknol
markknol / Life.hx
Created May 25, 2018 09:15
Life = life
package com.mediamonks.game.state;
import flambe.Component;
import flambe.util.Value;
/**
* Life.
*
* To follow the clues and walk out the exit.
* To know and master the world.
@markknol
markknol / how-to-draw-circle-oval-with-haxe-javascript.md
Last active August 16, 2021 11:28
Create oval / circle with bezierCurveTo in Haxe / Javascript

How to draw a circle or oval with Haxe/JavaScript

public static function oval(g:Graphics, w:Float, h:Float, cx:Float = 0, cy:Float = 0):Graphics {
	var lx = cx - w * .5;
	var rx = cx + w * .5;
	var ty = cy - h * .5;
	var by = cy + h * .5;

	var magic = 0.551915024494; 
@markknol
markknol / combinators.hx
Last active February 20, 2018 19:45 — forked from Avaq/combinators.js
Common combinators in Haxe 4
static final I = x -> x;
static final K = x -> y -> x;
static final A = f -> x -> f(x);
static final T = x -> f -> f(x);
static final W = f -> x -> f(x)(x);
static final C = f -> y -> x -> f(x)(y);
static final B = f -> g -> x -> f(g(x));
static final S = f -> g -> x -> f(x)(g(x));
static final P = f -> g -> x -> y -> f(g(x))(g(y));
@markknol
markknol / commands.md
Created January 25, 2018 22:10
Haxe.org git commands

Update Haxe Manual submodule

cd manual && git checkout master && git pull && cd .. && git commit -am "update manual"

Put from staging to master

git checkout master && git pull && git pull origin staging --rebase && git push && git checkout staging
@markknol
markknol / empty-haxe-project-size.md
Last active January 8, 2018 16:11
Empty Haxe project size

Size of empty Haxe/JavaScript project

openfl kha heaps pixi.js
normal 1027kb 358kb 1460kb 1250kb
closure 533kb 181kb 829kb 415kb

Used compiler: Haxe 3.4.2


@markknol
markknol / Main.hx
Last active January 2, 2018 08:54
Heaps Nape
package game;
import h2d.Bitmap;
import h2d.Sprite;
import hxd.Res;
import nape.geom.Vec2;
import nape.phys.Body;
import nape.phys.BodyType;
import nape.shape.Polygon;
import nape.space.Space;
@markknol
markknol / CSVReader.hx
Last active October 2, 2017 14:48
Haxe CSV Parser / Reader
using StringTools;
class CSVReader
{
private static var format:CSVFormat = { del: ",", quote: '"', escape: '""', linedel: "\r\n" };
private var csv:String;
public function new(csv:String)
{
this.csv = csv;