Skip to content

Instantly share code, notes, and snippets.

@swissmanu
swissmanu / gist:4284339
Created December 14, 2012 10:27
Draws a smiley face under iOS. Pass a mood value ranging from 0 to 1 for making it happy (or sad :( )
/**
* Draws a smiley inside the given rectangle. The mood value (0...1) is used
* to make the smiley happy or sad.
*
* @param rect Rectangle to draw the smiley into
* @param mood Happy (= 1) or sad (= 0) or anything in between
*/
-(void)drawSmileyInRect:(CGRect)rect withMood:(float)mood {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
@swissmanu
swissmanu / gist:2642579
Created May 9, 2012 07:06
simplyfied requestAnimationFrame
/**
* An even more common approach to look for vendor specific implementations in
* the browsers javascript object model.
* lookUpImplementation(vendors,subject,functionName,replacement) is reusable
* for other tasks too :-)
*/
var vendors = ['webkit','moz','o','ms'];
window.requestAnimationFrame = lookUpImplementation(
vendors, window, 'requestAnimationFrame'
,function(step) {