-
-
Save timmyc/1607828 to your computer and use it in GitHub Desktop.
Some categories for http://sparrow-framework.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Sparrow+SI.h | |
// | |
#import <UIKit/UIKit.h> | |
@interface SPUtils (DeviceAdditions) | |
+ (BOOL)isDevicePad; | |
+ (BOOL)isDeviceRetina; | |
@end | |
@implementation SPUtils (DeviceAdditions) | |
+ (BOOL)isDevicePad | |
{ | |
static int result = -1; | |
if (result == -1) | |
{ | |
result = ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] && [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad); | |
} | |
return (BOOL)result; | |
} | |
+ (BOOL)isDeviceRetina | |
{ | |
static int result = -1; | |
if (result == -1) | |
{ | |
result = ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0); | |
} | |
return (BOOL)result; | |
} | |
@end | |
@interface SPDisplayObject (Centering) | |
@property (nonatomic, assign) SPPoint *center; | |
@end | |
@implementation SPDisplayObject (Centering) | |
- (SPPoint *)center | |
{ | |
return [SPPoint pointWithX:self.x+self.width/2 y:self.y+self.height/2]; | |
} | |
- (void)setCenter:(SPPoint *)center | |
{ | |
self.x = center.x-self.width/2; | |
self.y = center.y-self.height/2; | |
} | |
@end | |
@implementation SPGLTexture (NearestNeighbor) | |
- (void)setFilter:(SPTextureFilter)filterType | |
{ | |
mFilter = SPTextureFilterNearestNeighbor; | |
glBindTexture(GL_TEXTURE_2D, mTextureID); | |
int magFilter = GL_NEAREST; | |
int minFilter = mMipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST; | |
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); | |
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment