Skip to content

Instantly share code, notes, and snippets.

🎸
#Haxe

Mark Knol markknol

🎸
#Haxe
Block or report user

Report or block markknol

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@markknol
markknol / DateUtil.hx
Last active Jun 12, 2019
DateUtil Outputs "xx days/weeks/days/minutes/seconds ago" https://try.haxe.org/#21f31
View DateUtil.hx
class DateUtil {
public static function format(target:Date) {
var secondsInMs = 1000;
var minuteInMs = secondsInMs * 60;
var hourInMs = minuteInMs * 60;
var dayInMs = hourInMs * 24;
var targetTime = target.getTime();
var now = Date.now().getTime();
@markknol
markknol / shadertoy.md
Last active Jun 7, 2019
Shader cheatsheet (from shadertoy)
View shadertoy.md

This help only covers the parts of GLSL ES that are relevant for Shadertoy. For the complete specification please have a look at GLSL ES specification

Language:

Version: WebGL 2.0
Arithmetic: ( ) + - ! * / %
Logical/Relatonal: ~ < > <= >= == != && ||
Bit Operators: & ^ | << >>
Comments: // /* */
Types: void bool int uint float vec2 vec3 vec4 bvec2 bvec3 bvec4 ivec2 ivec3 ivec4 uvec2 uvec3 uvec4 mat2 mat3 mat4 mat?x? sampler2D, sampler3D samplerCube
Format: float a = 1.0; int b = 1; uint i = 1U; int i = 0x1;

@markknol
markknol / ArrayUtils.hx
Created May 17, 2019
Support `for(index => value in array)` syntax in Haxe
View ArrayUtils.hx
class ArrayUtils {
/**
Support `for(index => value in array)` syntax.
**/
public static inline function keyValueIterator<A>(arr:Array<A>) {
return new ArrayKeyValueIterator(arr);
}
}
private class ArrayKeyValueIterator<T>{
View HAXEDEVELOP-DARK-THEME.fdi
# FD UI THEME (5.3+)
# Use themes in dialogs?
SmartForm.UseTheme=True
# Should we use custom border?
ThemeManager.UseCustomBorder=True
# Apply even if set to None?
ThemeManager.ForceBorderStyle=False
@markknol
markknol / LutShader.hx
Created Mar 19, 2019
LUT shader (uses 512x512 textures)
View LutShader.hx
class LutShader extends h3d.shader.ScreenShader {
static var SRC = {
@param var texture : Sampler2D;
@param var lookup1 : Sampler2D;
@param var lookup2 : Sampler2D;
@param var mixAmount : Float = 0.0;
@param var totalMixAmount : Float = 1.0;
function calcLookup(color:Vec4, lookupTexture:Sampler2D):Vec4 {
var blueColor = color.b * 63.0;
@markknol
markknol / Main.hx
Created Sep 21, 2018
Rainbow colors
View Main.hx
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 Jul 17, 2018
Publish to Haxelib (using Travis) using Github Releases
View Publish to Haxelib using Travis.md

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.
View Life.hx
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 May 15, 2018
Create oval / circle with bezierCurveTo in Haxe / Javascript
View how-to-draw-circle-oval-with-haxe-javascript.md

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; 
You can’t perform that action at this time.