Skip to content

Instantly share code, notes, and snippets.

@pixelrevision
pixelrevision / PixelLevelCollision.js
Last active January 23, 2018 19:28
PixelLevelCollision.js
/*
Works with the alpha channel of an image to determine if there is collision with alpha
@parameter image - the image to check coordinate with.
@parameter sampling - (0.1-1.0) The percentage to downsample the image. Helps with performance and memory. Default 0.5
@parameter threshhold - (0.0-1.0) the threshhold to set the alpha for a hit. default 0.2
*/
var PixelLevelCollision = function(image, sampling, threshhold){
var self = this;
if(sampling === undefined){
@pixelrevision
pixelrevision / PXRPropSerializer.h
Created February 6, 2014 01:17
Property Serializer
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
typedef enum {
PXRPropSerializerTypeUnknown,
PXRPropSerializerTypeFloat,
PXRPropSerializerTypeDouble,
PXRPropSerializerTypeInt,
PXRPropSerializerTypeClass,
PXRPropSerializerTypeBool
@pixelrevision
pixelrevision / excel_to_table.py
Last active December 28, 2015 05:59
Creates html tables from an excel doc
#!/usr/bin/python
import os
import shutil
import xlrd
import argparse
import xml.etree.ElementTree as elementTree
import xml.dom.minidom as minidom
def parseExcelDoc(xlsFile, outputFile, useTableHeader):
print xlsFile
@pixelrevision
pixelrevision / resize_ios_images.py
Last active December 21, 2015 11:39
Resize iOS images
'''
requires imagemagick to be installed. http://www.imagemagick.org/script/index.php
requires pngquant to be installed if using compression on pngs. http://pngquant.org/
'''
import os
import sys
import subprocess
import argparse
import shutil
import mimetypes
@pixelrevision
pixelrevision / resize_android_images.py
Last active December 19, 2015 06:49
Process Android images
'''
requires imagemagick to be installed. http://www.imagemagick.org/script/index.php
'''
import os
import sys
import subprocess
import argparse
# defines the input we want to use. Change the directory name or the target DPI to set this.
inputDirName = "drawable-xhdpi"
@pixelrevision
pixelrevision / crop_images.py
Last active December 17, 2015 02:39
Image cropping with coordinates in file name
'''
Script to crop dead space in images and save out coordinates in the file name. Requires PIL to be installed:
http://www.pythonware.com/products/pil/
usage:
python crop_images.py path/to/input/dir path/to/output/dir
'''
from PIL import Image
from PIL import ImageOps
import os
import sys
@pixelrevision
pixelrevision / PXRImageSizeUtil.h
Created April 15, 2013 23:21
A image resizing utility for iOS
#import <Foundation/Foundation.h>
typedef enum {
PXRImageSizeUtilVerticalAlignTop,
PXRImageSizeUtilVerticalAlignBottom,
PXRImageSizeUtilVerticalAlignMiddle
}PXRImageSizeUtilVerticalAlign;
typedef enum {
PXRImageSizeUtilHorizontalAlignLeft,
@pixelrevision
pixelrevision / PXRWebViewMessenger.js
Last active December 16, 2015 06:29
Call native iOS methods in javascript.
var PXRWebViewMessenger = function(){
this.prefixTrigger = "pxr";
this.queue = [];
this.timer = null;
};
PXRWebViewMessenger.prototype.callMethod = function(methodName, params){
var self = this;
var message = {};
message.method = methodName;
@pixelrevision
pixelrevision / ISO 8601 date
Created March 19, 2013 21:42
Get a date from a ISO 8601 string in javascript.
var a = dateString.split(/[^0-9]/);
var date = new Date (a[0],a[1]-1,a[2],a[3],a[4],a[5]);
@pixelrevision
pixelrevision / gist:5069770
Created March 2, 2013 04:58
Print all font family names in ios
NSArray *familyNames = [UIFont familyNames];
for(NSString *family in familyNames){
NSLog(@"-%@", family);
NSArray *fontNames = [UIFont fontNamesForFamilyName:family];
for(NSString *font in fontNames){
NSLog(@"----%@", font);
}
}