Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Init
- Loading branch information
0 parents
commit 8ea9a82
Showing
50 changed files
with
2,608 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Xcode | ||
build/* | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
*.xcworkspace | ||
!default.xcworkspace | ||
xcuserdata | ||
profile | ||
*.moved-aside | ||
DerivedData | ||
.DS_Store |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// CALayer+DSGraphics.h | ||
// | ||
// Copyright (c) 2012 Discontinuity S.r.l. Unipersonale. All rights reserved. | ||
// | ||
|
||
#import <QuartzCore/QuartzCore.h> | ||
|
||
/** | ||
Convenience methods for CALayer animations. | ||
*/ | ||
@interface CALayer (DSAnimations) | ||
|
||
/** | ||
Start a quick pop up animation on the receiver. | ||
*/ | ||
- (void)addPopUpAnimation; | ||
|
||
@end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// CALayer+DSGraphics.m | ||
// | ||
// Copyright (c) 2012 Discontinuity S.r.l. Unipersonale. All rights reserved. | ||
// | ||
|
||
#import "CALayer+DSAnimations.h" | ||
|
||
@implementation CALayer (DSAnimations) | ||
|
||
- (void)addPopUpAnimation | ||
{ | ||
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; | ||
|
||
CATransform3D scale1 = CATransform3DMakeScale(0.5, 0.5, 1); | ||
CATransform3D scale2 = CATransform3DMakeScale(1.2, 1.2, 1); | ||
CATransform3D scale3 = CATransform3DMakeScale(0.9, 0.9, 1); | ||
CATransform3D scale4 = CATransform3DMakeScale(1.0, 1.0, 1); | ||
|
||
NSArray *frameValues = [NSArray arrayWithObjects: | ||
[NSValue valueWithCATransform3D:scale1], | ||
[NSValue valueWithCATransform3D:scale2], | ||
[NSValue valueWithCATransform3D:scale3], | ||
[NSValue valueWithCATransform3D:scale4], | ||
nil]; | ||
|
||
[animation setValues:frameValues]; | ||
|
||
NSArray *frameTimes = [NSArray arrayWithObjects: | ||
[NSNumber numberWithFloat:0.0], | ||
[NSNumber numberWithFloat:0.5], | ||
[NSNumber numberWithFloat:0.9], | ||
[NSNumber numberWithFloat:1.0], | ||
nil]; | ||
[animation setKeyTimes:frameTimes]; | ||
|
||
animation.fillMode = kCAFillModeForwards; | ||
animation.duration = .25; | ||
|
||
[self addAnimation:animation forKey:@"DSPopUpAnimation"]; | ||
} | ||
|
||
@end | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// DSGraphicsKit.h | ||
// | ||
// Copyright (c) 2012 Discontinuity S.r.l. Unipersonale. All rights reserved. | ||
// | ||
|
||
// Images | ||
|
||
#import "DSCoreGraphicsFunctions.h" | ||
#import "UIImage+DSIcons.h" | ||
#import "UIImage+DSResizeAndRound.h" | ||
|
||
// Views | ||
|
||
#import "DSReflectionLayer.h" | ||
#import "UIView+DSImages.h" | ||
#import "CALayer+DSImages.h" | ||
|
||
// Animations | ||
|
||
#import "CALayer+DSAnimations.h" | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// DSCoreGraphicsFunctions.h | ||
// | ||
// Copyright (c) 2012 Discontinuity S.r.l. Unipersonale. All rights reserved. | ||
// | ||
|
||
/** DSCoreGraphics provides functions to perform common editing actions in Core Graphics. */ | ||
|
||
/** Identifies the corners of an image. */ | ||
typedef enum { | ||
DSCornerNone = 0x00000000, | ||
DSCornerAll = 0xFFFFFFFF, | ||
|
||
DSCornerTop = 0x0000000F, | ||
DSCornerTopRight = 1 << 0, | ||
DSCornerTopLeft = 1 << 1, | ||
|
||
DSCornerBottom = 0x000000F0, | ||
DSCornerBottomLeft = 1 << 4, | ||
DSCornerBottomRight = 1 << 5, | ||
|
||
} DSCorner; | ||
|
||
/** Creates a rounded rectangle path. | ||
@param rect The rect to round. | ||
@param radius The radius of the rounding. | ||
@param corner A bit enumerator mask specifing the corners to round. | ||
@return A CGMutablePathRef containing the rounded rectangle. | ||
*/ | ||
CGMutablePathRef DSRoundedRectCreate(CGRect rect, CGFloat radius, DSCorner corner); | ||
|
||
/** Clips a core graphics context with a rounded rect. | ||
@param ctx The core graphics context to clip. | ||
@param rect The rectangle to clip. | ||
@param radius The corner radius of the rectangle. | ||
@param corner The corners to round of the rectangle. | ||
*/ | ||
void DSContextClipForRoundCorners(CGContextRef ctx, CGRect rect, CGFloat radius, DSCorner corner); | ||
|
||
/** Draws a vertical gradient in a core graphics context. | ||
@param ctx The core graphics context to clip. | ||
@param startHeight The vertical coordinate where the gradient should start. | ||
@param stopHeight The height of the gradient. | ||
@param color1 The start color of the gradient. | ||
@param color2 The end color of the gradient. | ||
*/ | ||
void DSContextDrawVerticalGradient(CGContextRef ctx, CGFloat startHeight, CGFloat stopHeight, CGColorRef color1, CGColorRef color2); | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// DSCoreGraphics.c | ||
// | ||
// Copyright (c) 2012 Discontinuity S.r.l. Unipersonale. All rights reserved. | ||
// | ||
|
||
#import "DSCoreGraphicsFunctions.h" | ||
|
||
CGMutablePathRef DSRoundedRectCreate(CGRect rect, CGFloat radius, DSCorner corner) | ||
{ | ||
CGFloat | ||
x = rect.origin.x, | ||
y = rect.origin.y, | ||
x2 = rect.size.width + x, | ||
y2 = rect.size.height + y, | ||
topLeftRadius = corner & DSCornerTopLeft ? radius : 0, | ||
bottomLeftRadius = corner & DSCornerBottomLeft ? radius : 0, | ||
bottomRightRadius = corner & DSCornerBottomRight ? radius : 0, | ||
topRightRadius = corner & DSCornerTopRight ? radius : 0; | ||
|
||
CGMutablePathRef path = CGPathCreateMutable(); | ||
|
||
CGPathMoveToPoint(path, NULL, topLeftRadius, y); | ||
|
||
// 1. Top Left | ||
CGPathAddLineToPoint(path, NULL, x2 - topLeftRadius, y); | ||
CGPathAddArcToPoint(path, NULL, x2, y, x2, topLeftRadius, topLeftRadius); | ||
|
||
// 2. Bottom Left | ||
CGPathAddLineToPoint(path, NULL, x2, y2 - bottomLeftRadius); | ||
CGPathAddArcToPoint(path, NULL, x2, y2, x2 - bottomLeftRadius, y2, bottomLeftRadius); | ||
|
||
// 3. Bottom Right | ||
CGPathAddLineToPoint(path, NULL, bottomRightRadius, y2); | ||
CGPathAddArcToPoint(path, NULL, x, y2, x, y2 - bottomRightRadius, bottomRightRadius); | ||
|
||
// 4. Top Right | ||
CGPathAddLineToPoint(path, NULL, x, topRightRadius); | ||
CGPathAddArcToPoint(path, NULL, x, y, topRightRadius, y, topRightRadius); | ||
|
||
CGPathCloseSubpath(path); | ||
|
||
return path; | ||
} | ||
|
||
|
||
|
||
void DSContextClipForRoundCorners(CGContextRef ctx, CGRect rect, CGFloat radius, DSCorner corner) | ||
{ | ||
CGPathRef path = DSRoundedRectCreate(rect, radius, corner); | ||
CGContextAddPath(ctx, path); | ||
CGPathRelease(path); | ||
CGContextClip(ctx); | ||
} | ||
|
||
void DSContextDrawVerticalGradient(CGContextRef ctx, CGFloat y, CGFloat height, CGColorRef color1, CGColorRef color2) | ||
{ | ||
CGPoint start = CGPointMake(0.0, y); | ||
CGPoint stop = CGPointMake(0.0, y + height); | ||
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); | ||
NSMutableArray *colors = [NSMutableArray arrayWithObjects:(__bridge id)color1, (__bridge id)color2, nil]; | ||
|
||
CGGradientRef gradient = CGGradientCreateWithColors(space, (__bridge CFArrayRef)colors, NULL); | ||
|
||
CGContextDrawLinearGradient(ctx, gradient, start, stop, 0); | ||
|
||
CGColorSpaceRelease(space); | ||
CGGradientRelease(gradient); | ||
} | ||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// UIImage+DSGraphicsIcons.h | ||
// | ||
// Copyright (c) 2012 Discontinuity S.r.l. Unipersonale. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
/** Provides for generating icons from images. */ | ||
@interface UIImage (DSIcons) | ||
|
||
|
||
/** | ||
Adds to the current image the alpha channel of a given one and can optionally | ||
add a glow/shadow, a solid color background and round the corners of the image. | ||
@param alphaImage The image that provides the alpha chanel. | ||
@param bakgroundColor The color for the background. | ||
@param glowWidth The width of the glow. | ||
@param glowOffset The offset of the glow. | ||
@param glowColor The color of the glow. | ||
@param cornerRadius The radius of the corners. | ||
@return The modified copy of the image. | ||
*/ | ||
- (UIImage *)applyAlphaFromImage:(UIImage *)alphaImage | ||
backgroundColor:(UIColor*)bakgroundColor | ||
glowWidth:(CGFloat)glowWidth | ||
glowOffset:(CGSize)glowOffset | ||
glowColor:(UIColor *)glowColor | ||
cornerRadius:(CGFloat)cornerRadius; | ||
|
||
/** | ||
Adds to the current image the alpha channel of a given one and can optionally | ||
add a glow/shadow. | ||
Equivalent to call [UIImage applyAlphaFromImage:withBackgroundColor:glowWidth:glowOffset:glowColor:cornerRadius:] | ||
with no conerRadius and no backgroundColor. | ||
@param alphaImage The image for getting the alpha chanel. | ||
@param glowWidth The width of the glow. | ||
@param glowOffset The offset of the glow. | ||
@param glowColor The color of the glow. | ||
@return The modified copy of the image. | ||
*/ | ||
- (UIImage *)applyAlphaFromImage:(UIImage *)alphaImage | ||
glowWidth:(CGFloat)glowWidth | ||
offset:(CGSize)glowOffset | ||
color:(UIColor *)glowColor; | ||
|
||
/** | ||
Paints the alpha channel of the receiver with a given image, fills the | ||
background with the given color and rounds the image to a given corner radius. | ||
@param foreground The image to use for filling the alpha. | ||
@param backgroundColor The color to use for the background. | ||
@param radius The corner radius of the resulting image. | ||
@return The modified copy of the image. | ||
*/ | ||
- (UIImage*)iconWithForeground:(UIImage*)foreground background:(UIColor*)backgroundColor radius:(CGFloat)radius; | ||
|
||
|
||
///--------------------- | ||
/// @name Glowing fills | ||
///--------------------- | ||
|
||
|
||
/** Fills an image alpha channel with a gradient and adds a subtle drop shadow. | ||
The vertical gradient spans from 0.2 to 0.8 of the height of the image. | ||
@param colors Array containing two UIColors to use for creating the gradient. | ||
The colors must be in the RGB color space ie. [UIColor colorWithWhite:alpha:] | ||
is not allowed. | ||
@return A new image filled with the gradient. | ||
*/ | ||
- (UIImage *)gradientIconWithRGBColors:(NSArray *)colors; | ||
|
||
/** Returns a light gray icon. */ | ||
- (UIImage *)lightIcon; | ||
|
||
/** Returns a gray icon. */ | ||
- (UIImage *)grayIcon; | ||
|
||
/** Returns a dark gray icon. */ | ||
- (UIImage *)darkIcon; | ||
|
||
@end |
Oops, something went wrong.