This repository has been archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move sample app, add corner radius and unfinished bevel.
- Loading branch information
1 parent
76e0b5a
commit 6e78568
Showing
19 changed files
with
426 additions
and
306 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,21 @@ | ||
// | ||
// AKBevelImageEffect.h | ||
// AmazeKit | ||
// | ||
// Created by Jeffrey Kelley on 6/12/12. | ||
// Copyright (c) 2012 Detroit Labs. All rights reserved. | ||
// | ||
|
||
|
||
#import "AKImageEffect.h" | ||
|
||
|
||
@interface AKBevelImageEffect : AKImageEffect | ||
|
||
// The color of the bevel. | ||
@property (strong) UIColor *color; | ||
|
||
// The maximum radius of the bevel. | ||
@property (assign) CGFloat radius; | ||
|
||
@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,69 @@ | ||
// | ||
// AKBevelImageEffect.m | ||
// AmazeKit | ||
// | ||
// Created by Jeffrey Kelley on 6/12/12. | ||
// Copyright (c) 2012 Detroit Labs. All rights reserved. | ||
// | ||
|
||
|
||
#import "AKBevelImageEffect.h" | ||
|
||
#import "UIImage+AKPixelData.h" | ||
|
||
|
||
@implementation AKBevelImageEffect | ||
|
||
@synthesize color = _color; | ||
@synthesize radius = _radius; | ||
|
||
- (id)init | ||
{ | ||
self = [super init]; | ||
|
||
if (self) { | ||
_radius = 1.0f; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (UIImage *)renderedImageFromSourceImage:(UIImage *)sourceImage | ||
{ | ||
// Get the pixel data of the source image. | ||
NSData *pixelData = [sourceImage AK_rawRGBA8888Data]; | ||
|
||
uint8_t *rawData = [pixelData bytes]; | ||
|
||
NSUInteger width = [sourceImage size].width; | ||
NSUInteger height = [sourceImage size].height; | ||
|
||
uint8_t *foo; | ||
|
||
// Create a data buffer to write data into. | ||
|
||
// For every pixel, if it’s transparent and the pixel below it is not, add to the overlay | ||
// buffer below according to the radius. | ||
for (NSUInteger x = 0; x < width; x++) { | ||
for (NSUInteger y = 0; y < height - 1; y++) { | ||
// Is the current pixel “lit”? | ||
AKPixelData pixelData = AKGetPixelDataFromRGBA8888Data(rawData, width, height, x, y); | ||
|
||
if (pixelData.alpha == 0.0f) { | ||
AKPixelData pixelDataUnderneath = AKGetPixelDataFromRGBA8888Data(rawData, width, height, x, y + 1); | ||
|
||
if (pixelDataUnderneath.alpha >= 0.01f) { | ||
|
||
} | ||
|
||
NSUInteger yToInspect = y - 1; | ||
|
||
while (yToInspect >= 0) { | ||
// distanceToUnlit++; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@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,38 @@ | ||
// | ||
// AKCornerRadiusImageEffect.h | ||
// AmazeKit | ||
// | ||
// Created by Jeffrey Kelley on 6/12/12. | ||
// Copyright (c) 2012 Detroit Labs. All rights reserved. | ||
// | ||
|
||
|
||
#import "AKImageEffect.h" | ||
|
||
|
||
typedef struct { | ||
CGFloat topLeft; | ||
CGFloat topRight; | ||
CGFloat bottomLeft; | ||
CGFloat bottomRight; | ||
} AKCornerRadii; | ||
|
||
static inline AKCornerRadii | ||
AKCornerRadiiMake(CGFloat topLeft, CGFloat topRight, CGFloat bottomLeft, CGFloat bottomRight) | ||
{ | ||
AKCornerRadii radii; | ||
|
||
radii.topLeft = topLeft; | ||
radii.topRight = topRight; | ||
radii.bottomLeft = bottomLeft; | ||
radii.bottomRight = bottomRight; | ||
|
||
return radii; | ||
} | ||
|
||
@interface AKCornerRadiusImageEffect : AKImageEffect | ||
|
||
// The corner radii can be set independently. | ||
@property (assign) AKCornerRadii cornerRadii; | ||
|
||
@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,72 @@ | ||
// | ||
// AKCornerRadiusImageEffect.m | ||
// AmazeKit | ||
// | ||
// Created by Jeffrey Kelley on 6/12/12. | ||
// Copyright (c) 2012 Detroit Labs. All rights reserved. | ||
// | ||
|
||
|
||
#import "AKCornerRadiusImageEffect.h" | ||
|
||
|
||
@implementation AKCornerRadiusImageEffect | ||
|
||
@synthesize cornerRadii = _cornerRadii; | ||
|
||
- (UIImage *)renderedImageFromSourceImage:(UIImage *)sourceImage | ||
{ | ||
CGFloat width = [sourceImage size].width; | ||
CGFloat height = [sourceImage size].height; | ||
|
||
// Create the mask image. | ||
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); | ||
|
||
CGContextRef context = CGBitmapContextCreate(NULL, | ||
width, | ||
height, | ||
8, | ||
8 * width, | ||
colorSpace, | ||
kCGImageAlphaNone); | ||
|
||
CGContextBeginPath(context); | ||
CGContextSetGrayFillColor(context, 1.0, 0.0); | ||
CGContextAddRect(context, CGRectMake(0.0f, 0.0f, width, height)); | ||
CGContextClosePath(context); | ||
CGContextDrawPath(context, kCGPathFill); | ||
|
||
CGContextSetGrayFillColor(context, 1.0, 1.0); | ||
CGContextBeginPath(context); | ||
CGContextMoveToPoint(context, 0.0f, height / 2.0f); | ||
CGContextAddArcToPoint(context, 0.0f, 0.0f, width / 2.0f, 0.0f, [self cornerRadii].bottomLeft); | ||
CGContextAddArcToPoint(context, width, 0.0f, width, height / 2.0f, [self cornerRadii].bottomRight); | ||
CGContextAddArcToPoint(context, width, height, width / 2.0f, height, [self cornerRadii].topRight); | ||
CGContextAddArcToPoint(context, 0.0f, height, 0.0f, height / 2.0f, [self cornerRadii].topLeft); | ||
CGContextClosePath(context); | ||
CGContextDrawPath(context, kCGPathFill); | ||
|
||
CGImageRef mask = CGBitmapContextCreateImage(context); | ||
|
||
CGContextRelease(context); | ||
context = NULL; | ||
|
||
// Render the noise layer on top of the source image. | ||
UIGraphicsBeginImageContextWithOptions([sourceImage size], NO, 0.0f); | ||
context = UIGraphicsGetCurrentContext(); | ||
|
||
CGContextScaleCTM(context, 1.0f, -1.0f); | ||
CGContextTranslateCTM(context, 0.0f, -height); | ||
|
||
CGImageRef maskedOriginalImage = CGImageCreateWithMask([sourceImage CGImage], mask); | ||
CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), maskedOriginalImage); | ||
|
||
UIImage *renderedImage = UIGraphicsGetImageFromCurrentImageContext(); | ||
|
||
UIGraphicsEndImageContext(); | ||
context = NULL; | ||
|
||
return renderedImage; | ||
} | ||
|
||
@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
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
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
2 changes: 1 addition & 1 deletion
2
SmapleApp/SmapleApp/AKAppDelegate.h → AmazeKit/SampleApp/AKAppDelegate.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
2 changes: 1 addition & 1 deletion
2
SmapleApp/SmapleApp/AKAppDelegate.m → AmazeKit/SampleApp/AKAppDelegate.m
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
File renamed without changes.
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
SmapleApp/SmapleApp/SmapleApp-Prefix.pch → AmazeKit/SampleApp/SampleApp-Prefix.pch
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
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.