Skip to content

Instantly share code, notes, and snippets.

@makc
makc / pixel.js
Created November 30, 2022 06:48
Colored pixel GIF
function pixelDataURL (r, g, b) {
return 'data:image/gif;base64,' +
btoa(
[71,73,70,56,57,97,1,0,1,0,128,0,0,r,g,b,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59]
.map(c => String.fromCharCode(c))
.join('')
)
;
}
@makc
makc / InstanceMetadataEditor.as
Created September 5, 2013 03:40
Instance metadata editor
package {
import com.bit101.components.PushButton;
import com.bit101.components.TextArea;
import com.codeazur.as3swf.SWF;
import com.codeazur.as3swf.tags.*;//TagPlaceObject;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
@makc
makc / gist:4055965
Created November 11, 2012 19:24
Integral image
var w:int = bitmapData.width, w1:int = w + 1, w2:int = w + 2, h:int = bitmapData.height, h1:int = h + 1, length:int = w1 * h1;
var integralImage:Vector.<int> = new Vector.<int> (length, true);
var vec:Vector.<uint> = bitmapData.getVector (bitmapData.rect);
var i/*nput*/:int = 0, o/*utput*/:int = w2, s:int;
for (var y:int = 0; y < h; y++, o++) {
s = 0;
for (var x:int = 0; x < w; x++, o++, i++) {
@makc
makc / Pool.as
Created June 27, 2012 17:09
General purpose instance pool class (feel free to improve :)
package com.realaxy.operators{
import flash.utils.Dictionary;
internal class Pool {
private var instances : Dictionary =new Dictionary() ;
private var instanceCounts : Dictionary =new Dictionary() ;
public function getInstance ( type : Class ) : * {
var cache : Vector.<*>;
if ( instanceCounts[type] ) {