//
//  UIColor+ImageWithColorCreator.m
//  rainbow
//
//  Created by Doha Tubaileh on 1/19/20.
//  Copyright © 2020 Facebook. All rights reserved.
//

#import "UIColor+ImageWithColorCreator.h"


@implementation UIColor (ImageWithColorCreator)

- (UIImage *)imageFromColor {
    NSLog(@"[UIColor+ImageWithColorCreator] imageFromColor");
    
    CGRect rect = CGRectMake(0, 0, 1, 1);
    UIGraphicsBeginImageContext(rect.size);
    
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context,self.CGColor);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}

@end
