Skip to content
Browse files

Removed rand and srand fix #8

  • Loading branch information...
1 parent f01a750 commit ad2d5590c321e256110f3d707069faa15aad6ca0 @kgn committed Feb 15, 2013
Showing with 7 additions and 2 deletions.
  1. +7 −2 KGNoise.m
View
9 KGNoise.m
@@ -10,6 +10,11 @@
static NSUInteger const kKGNoiseImageSize = 128;
+NSInteger kgnoise_rseed = 115;
+static inline NSInteger kgnoise_rand(){
+ return (kgnoise_rseed = (kgnoise_rseed * 214013 + 2531011) & ((1U << 31) - 1)) >> 16;
+}
+
#if TARGET_OS_IPHONE
static inline CGFloat *gradientComponentsForColors(UIColor *color1, UIColor *color2){
#else
@@ -58,8 +63,8 @@ + (void)drawNoiseWithOpacity:(CGFloat)opacity andBlendMode:(CGBlendMode)blendMod
dispatch_once(&oncePredicate, ^{
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;}
+ char *rgba = (char *)malloc(size);
+ for(NSUInteger i=0; i < size; ++i){rgba[i] = kgnoise_rand()%256;}
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
CGContextRef bitmapContext =
CGBitmapContextCreate(rgba, width, height, 8, width, colorSpace, kCGImageAlphaNone);

0 comments on commit ad2d559

Please sign in to comment.
Something went wrong with that request. Please try again.