CS185c
Chris Pollett
Apr 16, 2012
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0); CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); CGContextMoveToPoint(context, 100.0f, 100.0f); CGContextAddLineToPoint(context, 200.0f, 200.0f); CGContextStrokePath(context);
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
[UIColor colorWithRed:1.0f green: 0.0f blue: 0.0f alpha:1.0f];
CGPoint drawPoint = CGPointMake(100.0f, 100.0f); [image drawAtPoint: drawPoint];
CGRect theRect = CGRectMake(0, 0, 100, 100); CGContextAddEllipseInRect(context, theRect); CGContextDrawPath(context, kCGPathFillStroke);
Which of the following is true?
#import <UIKit/UIKit.h> @interface UIColor(Random) +(UIColor *)randomColor; @end
#import "UIColor-Random.h" @implementation UIColor(Random) +(UIColor *)randomColor { static BOOL seeded = NO; if(!seeded) { seeded = YES; srandom(time(NULL)); } CGFloat red = (CGFloat)random()/(CGFloat)RAND_MAX; CGFloat blue = (CGFloat)random()/(CGFloat)RAND_MAX; CGFloat green = (CGFloat)random()/(CGFloat)RAND_MAX; return [UIColor colorWithRed: red green:green blue:blue alpha:1.0f]; } @end
typedef enum { kLineShape = 0, kRectShape, kEllipseShape, kImageShape } ShapeType; typedef enum { kRedColorTab = 0, kBlueColorTab, kYellowColorTab, kGreenColorTab, kRandomColorTab } ColorTabIndex; #define degreesToRadians(x) (3.1415926535897932846 * x /180)