5
// Created by döme on 17.08.2009.
6
// Copyright 2009 __MyCompanyName__. All rights reserved.
9
#import <UIKit/UIKit.h>
11
#import "GriddedImageWell.h"
15
@implementation GriddedImageWell
18
- (id)initWithFrame:(CGRect)frame {
19
if ((self = [super initWithFrame:frame])) {
20
// Initialization code
26
- (void) drawRect: (CGRect) rect
28
[super drawRect: rect];
30
CGRect bounds = [self bounds];
31
CGSize imageSize = CGSizeFitIntoSize([[self image] size], CGRectInset(bounds, 1.0f, 1.0f).size);
33
CGContextRef c = UIGraphicsGetCurrentContext();
34
CGContextSaveGState(c);
36
CGContextSetBlendMode(c, kCGBlendModeExclusion);
37
[[UIColor colorWithWhite: 0.5f*imageAlpha alpha: 1.0f] set];
41
for (int i = 1; i < hcells; ++i)
43
float xcoord = CGRectGetMidX(bounds) - 0.5*imageSize.width + (float)i*(imageSize.width/((float)(hcells)));
44
CGContextMoveToPoint(c, xcoord, CGRectGetMidY(bounds) - 0.5*imageSize.height);
45
CGContextAddLineToPoint(c, xcoord, CGRectGetMidY(bounds) + 0.5*imageSize.height);
46
CGContextStrokePath(c);
51
for (int i = 1; i < vcells; ++i)
53
float ycoord = CGRectGetMidY(bounds) - 0.5*imageSize.height + (float)i*(imageSize.height/((float)(vcells)));
54
CGContextMoveToPoint(c, CGRectGetMidX(bounds) - 0.5*imageSize.width, ycoord);
55
CGContextAddLineToPoint(c, CGRectGetMidX(bounds) + 0.5*imageSize.width, ycoord);
56
CGContextStrokePath(c);
61
CGContextRestoreGState(c);
70
- (void) setHcells: (int) num
73
[self setNeedsDisplay];
76
- (void) setVcells: (int) num
79
[self setNeedsDisplay];
84
@synthesize hcells, vcells;