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 / DrawMitre2.hx
Created July 21, 2024 01:36
Mitre Gradients.
package cornerContour._application;
import starling.rendering.IndexData;
import starling.rendering.VertexData;
import openfl.display.Sprite;
import openfl.events.Event;
import openfl.display.Graphics;
import openfl.display.BitmapData;
import openfl.geom.Vector3D;
// contour code
@nanjizal
nanjizal / DrawMitre.hx
Created July 9, 2024 18:59
Mitre support
public inline
function mitreDraw( ax_: Float, ay_: Float, bx_: Float, by_: Float, width_: Float, clockWise: Bool ){
// bx_, by_ currently not required... but incase.
// work out the opposite point to j, ie the mitre corner.
// calculate the difference from centre
var deltaX = ax_ - jx;
var deltaY = ay_ - jy;
// reflect j in relation to a
var mitreCornerX = ax_ + deltaX;
var mitreCornerY = ay_ + deltaY;
@nanjizal
nanjizal / AlphaBlend.hx
Last active May 4, 2024 09:16
Alpha blend pixel colors
public inline
function channelBlend( ch0: PixelChannel
, ch1: PixelChannel
, ch2: PixelChannel
, ch3: PixelChannel ){
var a1: Float = c0; // abstract conversion
var r1: Float = c1;
var g1: Float = c2;
var b1: Float = c3;
var a2: Float = ch0;
@nanjizal
nanjizal / Main.js
Created March 16, 2024 14:48
peote-view pi_xy test
(function ($hx_exports, $global) { "use strict"; var $hx_script = (function (exports, global) { // Generated by Haxe 4.3.3
(function ($hx_exports, $global) { "use strict";
$hx_exports["lime"] = $hx_exports["lime"] || {};
var $hxClasses = {},$estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_;
function $extend(from, fields) {
var proto = Object.create(from);
for (var name in fields) proto[name] = fields[name];
if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
return proto;
}
@nanjizal
nanjizal / Img.hx
Created March 6, 2024 20:40
Img.hx with Unt8Array
// package iterMagic;
https://try.haxe.org/#05CF3741
/*
Basic data structure to work with images made of Int, does not provide color specific manipulation.
*/
import haxe.ds.GenericStack; // assess to GenericCell
import haxe.ds.Vector;
typedef BytesInt = haxe.io.Bytes;
typedef ArrInt = Array<Int>;
@nanjizal
nanjizal / Test.hx
Created November 24, 2023 04:09
Freya's Hermite Monotonic curve
function main() {
trace("Freya Hermite Monotonic curve");
var w = 0.5;
var x = 0.;
for( x10 in 0...10 ){
x = x10/10;
trace( x + ' : ' + cubicMidpointEaseInOut( x, w ) );
}
trace( 1. + ' : ' + cubicMidpointEaseInOut( 1., w ) );
}
@nanjizal
nanjizal / Test.hx
Created November 5, 2023 10:29
multitype A
import haxe.ds.Vector;
function main() {
var a: A<ArrInt> = A.arrInt( 10 );
var v: A<VecInt> = A.vecInt( 10 );
a[3]=1;
v[2]=2;
trace( a[3] );
trace( v[2] );
}
typedef ArrInt = Array<Int>;
@nanjizal
nanjizal / Test.hx
Created October 29, 2023 23:10
StackImage
//https://try.haxe.org/#3C9bD72e
import haxe.ds.GenericStack; // assess to GenericCell
enum abstract ImageType(Int) {
var BYTES;
var ARRAY;
var UINT32ARRAY;
var VECTOR;
var GENERICSTACK;
}
@nanjizal
nanjizal / Test.hx
Last active October 28, 2023 15:13
Multitype image
//https://try.haxe.org/#d6768054
enum abstract ImageType( Int ) {
var BYTES;
var ARRAY;
var UINT32ARRAY;
var VECTOR;
}
@:access( IDataImage )
@:transitive
@:multiType
@nanjizal
nanjizal / Test.hx
Last active October 28, 2023 12:01
Testing DataImage
class HolderImage{
public var image: IDataImage;
public function new( image: IDataImage ){
this.image = image;
}
}
class Test {
static function main() {
var holderImage = new HolderImage( new ByteImage( 100, 100 ) );
var b = new UInt32ArrayImage(100, 100);