//
//  StrokedFilledSquareView.m
//  StrokedFilledSquare
//
//  Created by Bill Dudney on 12/11/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//
//
//  Licensed with the Apache 2.0 License
//  http://apache.org/licenses/LICENSE-2.0
//

#import "StrokedFilledSquareView.h"


@implementation StrokedFilledSquareView


- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // Initialization code
    }
    return self;
}


//START:code.strokedfilledview.drawRect:
- (void)drawRect:(CGRect)rect {
  // create and build the path
  CGMutablePathRef path = CGPathCreateMutable();
  CGPathMoveToPoint(path, NULL, 10.0f, 10.0f);
  CGPathAddLineToPoint(path, NULL, 100.0f, 10.0f);
  CGPathAddLineToPoint(path, NULL, 100.0f, 100.0f);
  CGPathAddLineToPoint(path, NULL, 10.0f, 100.0f);
  CGPathCloseSubpath(path);
  CGContextRef ctx = UIGraphicsGetCurrentContext();
  // configure the fill parameters and fill the path
  CGContextSetFillColorWithColor(ctx, [UIColor blueColor].CGColor);
  CGContextAddPath(ctx, path);
  CGContextFillPath(ctx);
  // configure the stroke parameters and stroke the path
  CGContextSetStrokeColorWithColor(ctx, [UIColor yellowColor].CGColor);
  CGContextSetLineWidth(ctx, 10.0f);
  CGContextAddPath(ctx, path);
  CGContextStrokePath(ctx);
  CGPathRelease(path);
}
//END:code.strokedfilledview.drawRect:

- (void)dealloc {
    [super dealloc];
}


@end
