Skip to content

Instantly share code, notes, and snippets.

View ConfidantCommunications's full-sized avatar
❄️
Chillin’

Allan Dowdeswell ConfidantCommunications

❄️
Chillin’
View GitHub Profile
@ConfidantCommunications
ConfidantCommunications / HeapsDrag.hx
Last active September 27, 2019 20:31
Heaps: Dragging object in 3D space
import h3d.col.Point;
import h3d.shader.ColorAdd;
import h3d.scene.fwd.DirLight;
import hxd.Event;
import hxd.fmt.grd.Data;
class HeapsDrag extends hxd.App {
var rnd : hxd.Rand;
var light : h3d.scene.fwd.DirLight;
@ConfidantCommunications
ConfidantCommunications / FitWithinAndCenter.hx
Last active December 9, 2019 16:56
Fitting OpenFL DisplayObject within bounds and center
var w = 800; //or whatever
var h = 300;
var obj = new Bitmap(someBitmapData);
var s = new Sprite();
s.graphics.beginFill(0x000000,0);
s.graphics.drawRect(0,0,w,h);
s.graphics.endFill();
var hRatio = obj.height / h;
var wRatio = obj.width / w;
if (wRatio > hRatio) {