Skip to content

Instantly share code, notes, and snippets.

@Antriel
Antriel / MyScene.ts
Created April 28, 2022 10:35
Phaser 3 SpriteFX Outline Shader
import OutlineSpriteFX from './OutlineSpriteFx';
export default class MyScene extends Phaser.Scene {
create() {
const pipeline:OutlineSpriteFX = this.renderer.pipelines.add('OutlineSpriteFX', new OutlineSpriteFX(this.game));
pipeline.thickness = 3;
pipeline.color.setFromRGB(Phaser.Display.Color.IntegerToRGB(0xff3333));
const sprite = this.add.sprite(100, 100, 'someSprite');
@Antriel
Antriel / ExprToEnumVal.hx
Last active May 15, 2020 10:57
Haxe Macros – Convert Expr of EnumValue to value inside macro context
import haxe.macro.ExprTools;
import haxe.macro.Context;
import haxe.macro.Type;
import haxe.macro.Expr;
import Type in StdType;
class ExprToEnumVal {
public static macro function foo(e:Expr) {
return switch exprToEnum(e, macro:ExprToEnumVal.Foo, Foo) {
case A: macro null;
@Antriel
Antriel / Singletonize.hx
Created January 14, 2020 20:49
Build macro to take all public functions of a class and add (lazy) singleton static function equivalents.
package antriel.macros;
import haxe.macro.Expr;
import haxe.macro.Context;
import haxe.macro.Expr.Position;
import haxe.macro.Type.ClassType;
using Lambda;
class Singletonize {
@Antriel
Antriel / Main.hx
Created May 8, 2019 19:49
Iron Perspective Triangle
package;
import iron.math.Vec4;
import iron.App;
import iron.Scene;
import iron.RenderPath;
import iron.data.*;
import iron.data.SceneFormat;
import iron.object.Object;
class Hideable extends View {
@:attribute var hidden:Bool;
@:attribute var fast:Bool = false;
@:attribute var getRender:ClassName->RenderResult;
@:attribute var animationIn:ClassName = "fadeIn";
@:attribute var animationOut:ClassName = "fadeOut";
@:computed var baseClass:ClassName = if (fast) ['animated', 'faster'] else ['animated'];
@:computed var classes:ClassName = baseClass.add(hidden ? animationOut : animationIn);
@:computed var hiddenDelay:Delayer<Bool> = new Delayer({ delay: fast ? 650 : 1150, source: hidden });