






#import "UIColor+LogColor.h"

@implementation UIColor (LogColor)

+ (UIColor *)cutMealIdentifyApertureAssumeNordic:(NSString *)plugMedia {
    if (plugMedia.length <= 0) return nil;
    
    NSString *autoCapture = [[plugMedia stringByReplacingOccurrencesOfString: @"#" withString: @""] uppercaseString];
    CGFloat alpha, red, blue, green;
    switch ([autoCapture length]) {
        case 3: 
            alpha = 1.0f;
            red   = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 0 length: 1];
            green = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 1 length: 1];
            blue  = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 2 length: 1];
            break;
        case 4: 
            alpha = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 0 length: 1];
            red   = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 1 length: 1];
            green = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 2 length: 1];
            blue  = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 3 length: 1];
            break;
        case 6: 
            alpha = 1.0f;
            red   = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 0 length: 2];
            green = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 2 length: 2];
            blue  = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 4 length: 2];
            break;
        case 8: 
            alpha = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 0 length: 2];
            red   = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 2 length: 2];
            green = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 4 length: 2];
            blue  = [self leaveIgnoredRingTrainerCrossSlant: autoCapture start: 6 length: 2];
            break;
        default: {
            NSAssert(NO, @"Color value %@ is invalid. It should be a hex value of the form #RBG, #ARGB, #RRGGBB, or #AARRGGBB", plugMedia);
            return nil;
        }
            break;
    }
    return [UIColor colorWithRed: red green: green blue: blue alpha: alpha];
}

+ (CGFloat)leaveIgnoredRingTrainerCrossSlant:(NSString *)string start:(NSUInteger)start length:(NSUInteger)length {
    NSString *substring = [string substringWithRange: NSMakeRange(start, length)];
    NSString *capsCup = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring];
    unsigned hexComponent;
    [[NSScanner scannerWithString: capsCup] scanHexInt: &hexComponent];
    return hexComponent / 255.0;
}

- (UIColor *)profilesPosterFavoritesLighterLogicalAdverb:(CGFloat)percentage {
    return [self gatewaysSaturateTruncateRelativeNetThumb:percentage];
}

- (UIColor *)disappearDesignVisualAtomEggRecovered:(CGFloat)percentage {
    return [self gatewaysSaturateTruncateRelativeNetThumb:-1*fabs(percentage)];
}

- (UIColor *)gatewaysSaturateTruncateRelativeNetThumb:(CGFloat)percentage {
    CGFloat red,green,blue,alpha;
    if ([self getRed:&red green:&green blue:&blue alpha:&alpha]) {
        return [UIColor colorWithRed:MIN(red+percentage/100, 1.0) green:MIN(green+percentage/100, 1.0) blue:MIN(blue+percentage/100, 1.0) alpha:alpha];
    }else {
        return nil;
    }
}

@end
