Skip to content

Instantly share code, notes, and snippets.

@pixelrevision
pixelrevision / PixelLevelCollision.js
Last active Jan 23, 2018
PixelLevelCollision.js
View 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){
View PXRPropSerializer.h
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
typedef enum {
PXRPropSerializerTypeUnknown,
PXRPropSerializerTypeFloat,
PXRPropSerializerTypeDouble,
PXRPropSerializerTypeInt,
PXRPropSerializerTypeClass,
PXRPropSerializerTypeBool
@pixelrevision
pixelrevision / excel_to_table.py
Last active Dec 28, 2015
Creates html tables from an excel doc
View excel_to_table.py
#!/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
View resize_ios_images.py
'''
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
View resize_android_images.py
'''
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 Dec 17, 2015
Image cropping with coordinates in file name
View crop_images.py
'''
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 Apr 15, 2013
A image resizing utility for iOS
View PXRImageSizeUtil.h
#import <Foundation/Foundation.h>
typedef enum {
PXRImageSizeUtilVerticalAlignTop,
PXRImageSizeUtilVerticalAlignBottom,
PXRImageSizeUtilVerticalAlignMiddle
}PXRImageSizeUtilVerticalAlign;
typedef enum {
PXRImageSizeUtilHorizontalAlignLeft,
@pixelrevision
pixelrevision / PXRWebViewMessenger.js
Last active Dec 16, 2015
Call native iOS methods in javascript.
View PXRWebViewMessenger.js
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 Mar 19, 2013
Get a date from a ISO 8601 string in javascript.
View ISO 8601 date
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 Mar 2, 2013
Print all font family names in ios
View gist:5069770
NSArray *familyNames = [UIFont familyNames];
for(NSString *family in familyNames){
NSLog(@"-%@", family);
NSArray *fontNames = [UIFont fontNamesForFamilyName:family];
for(NSString *font in fontNames){
NSLog(@"----%@", font);
}
}