Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix a Xcode warning #10

Merged
merged 3 commits into from

2 participants

@larcus94

Hi David,

I've just fixed a warning from Xcode that the function hasn't been declared before. Also, I've renamed the const to make the class a bit cleaner. Not big changes here but I was just feeling like fixing it.

Hope you like it,
Laurin

@larcus94

Ah no way! Didn't know that static inline solves this. Thanks :D.
Well kImageSize isn't really open to any other classes but I think it's useful when refactoring and so on comes in. "imageSize" is a common name for variables so when you search project wide for "image" or "size" you'll see immediately where it belongs too.
I usually do it this way but it's only a suggestion.

@kgn kgn merged commit f01a750 into from
@kgn
Owner
kgn commented

Thanks for the codes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 1, 2013
  1. Fix a warning

    Laurin authored
  2. rename the kImageSize const

    Laurin authored
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 6 deletions.
  1. +6 −6 KGNoise.m
View
12 KGNoise.m
@@ -8,12 +8,12 @@
#import "KGNoise.h"
-static NSUInteger const kImageSize = 128;
+static NSUInteger const kKGNoiseImageSize = 128;
#if TARGET_OS_IPHONE
-static CGFloat *gradientComponentsForColors(UIColor *color1, UIColor *color2){
+static inline CGFloat *gradientComponentsForColors(UIColor *color1, UIColor *color2){
#else
-static CGFloat *gradientComponentsForColors(NSColor *color1, NSColor *color2){
+static inline CGFloat *gradientComponentsForColors(NSColor *color1, NSColor *color2){
#endif
CGFloat *components = malloc(8*sizeof(CGFloat));
const CGFloat *alternateBackgroundComponents = CGColorGetComponents([color1 CGColor]);
@@ -56,7 +56,7 @@ + (void)drawNoiseWithOpacity:(CGFloat)opacity andBlendMode:(CGBlendMode)blendMod
static CGImageRef noiseImageRef = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
- NSUInteger width = kImageSize, height = width;
+ NSUInteger width = kKGNoiseImageSize, height = width;
NSUInteger size = width*height;
char *rgba = (char *)malloc(size); srand(115);
for(NSUInteger i=0; i < size; ++i){rgba[i] = rand()%256;}
@@ -106,7 +106,7 @@ - (UIColor *)colorWithNoiseWithOpacity:(CGFloat)opacity{
return [self colorWithNoiseWithOpacity:opacity andBlendMode:kCGBlendModeScreen];
}
- (UIColor *)colorWithNoiseWithOpacity:(CGFloat)opacity andBlendMode:(CGBlendMode)blendMode{
- CGRect rect = {CGPointZero, kImageSize, kImageSize};
+ CGRect rect = {CGPointZero, kKGNoiseImageSize, kKGNoiseImageSize};
UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[self setFill]; CGContextFillRect(context, rect);
@@ -122,7 +122,7 @@ - (NSColor *)colorWithNoiseWithOpacity:(CGFloat)opacity{
return [self colorWithNoiseWithOpacity:opacity andBlendMode:kCGBlendModeScreen];
}
- (NSColor *)colorWithNoiseWithOpacity:(CGFloat)opacity andBlendMode:(CGBlendMode)blendMode{
- CGRect rect = {CGPointZero, kImageSize, kImageSize};
+ CGRect rect = {CGPointZero, kKGNoiseImageSize, kKGNoiseImageSize};
NSImage *image = [[NSImage alloc] initWithSize:rect.size];
[image lockFocus];
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
Something went wrong with that request. Please try again.