RSS

(root)/iphone/common : 61 : Jigs/source/GriddedImageWell.m

To get this branch, use:
bzr branch /browse/iphone/common

« back to all changes in this revision

Viewing changes to Jigs/source/GriddedImageWell.m

Dömötör Gulyás
2010-01-18 09:03:51
Revision ID: dognotdog@gmail.com-20100118080351-ib2knxvk4w8ssw3h
made common a nested tree

Show diffs side-by-side

added added

removed removed

1
 
//
2
 
//  GriddedImageWell.m
3
 
//  Jigs
4
 
//
5
 
//  Created by döme on 17.08.2009.
6
 
//  Copyright 2009 __MyCompanyName__. All rights reserved.
7
 
//
8
 
 
9
 
#import <UIKit/UIKit.h>
10
 
 
11
 
#import "GriddedImageWell.h"
12
 
#import "geometry.h"
13
 
 
14
 
 
15
 
@implementation GriddedImageWell
16
 
 
17
 
 
18
 
- (id)initWithFrame:(CGRect)frame {
19
 
    if ((self = [super initWithFrame:frame])) {
20
 
        // Initialization code
21
 
    }
22
 
    return self;
23
 
}
24
 
 
25
 
 
26
 
- (void) drawRect: (CGRect) rect
27
 
{
28
 
        [super drawRect: rect];
29
 
        
30
 
        CGRect bounds = [self bounds];
31
 
        CGSize imageSize = CGSizeFitIntoSize([[self image] size], CGRectInset(bounds, 1.0f, 1.0f).size);
32
 
        
33
 
        CGContextRef c = UIGraphicsGetCurrentContext();
34
 
        CGContextSaveGState(c);
35
 
        
36
 
        CGContextSetBlendMode(c, kCGBlendModeExclusion);
37
 
        [[UIColor colorWithWhite: 0.5f*imageAlpha alpha: 1.0f] set];
38
 
 
39
 
        if (hcells > 1)
40
 
        {
41
 
                for (int i = 1; i < hcells; ++i)
42
 
                {
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);
47
 
                }
48
 
        }
49
 
        if (vcells > 1)
50
 
        {
51
 
                for (int i = 1; i < vcells; ++i)
52
 
                {
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);
57
 
                }
58
 
        }
59
 
 
60
 
 
61
 
        CGContextRestoreGState(c);
62
 
}
63
 
 
64
 
 
65
 
- (void)dealloc
66
 
{
67
 
    [super dealloc];
68
 
}
69
 
 
70
 
- (void) setHcells: (int) num
71
 
{
72
 
        hcells = num;
73
 
        [self setNeedsDisplay];
74
 
}
75
 
 
76
 
- (void) setVcells: (int) num
77
 
{
78
 
        vcells = num;
79
 
        [self setNeedsDisplay];
80
 
}
81
 
 
82
 
 
83
 
 
84
 
@synthesize hcells, vcells;
85
 
@end

Loggerhead 1.17 is a web-based interface for Bazaar branches