Source/DiscPiece.m
changeset 12 4e567e11f45f
parent 0 e9f7ba4718e1
child 13 db7bb080c3d5
     1.1 --- a/Source/DiscPiece.m	Fri Mar 07 11:43:02 2008 -0800
     1.2 +++ b/Source/DiscPiece.m	Mon Jul 07 15:47:42 2008 -0700
     1.3 @@ -27,27 +27,23 @@
     1.4  @implementation DiscPiece
     1.5  
     1.6  
     1.7 -- (void) setImage: (CGImageRef)image scale: (CGFloat)scale
     1.8 +- (void) _setImage: (CGImageRef)image
     1.9  {
    1.10 -    if( scale < 4.0 ) {
    1.11 -        int size = MAX(CGImageGetWidth(image), CGImageGetHeight(image));
    1.12 -        if( scale > 0 )
    1.13 -            scale = ceil( size * scale);
    1.14 -        else
    1.15 -            scale = size;
    1.16 -        scale *= 1.2;
    1.17 -    }
    1.18 -    self.bounds = CGRectMake(0,0,scale,scale);
    1.19 -    
    1.20 +    CGFloat diameter = MAX(CGImageGetWidth(image),CGImageGetHeight(image));
    1.21 +    CGFloat outerDiameter = round(diameter * 1.1);
    1.22 +    self.bounds = CGRectMake(0,0,outerDiameter,outerDiameter);
    1.23 +
    1.24      if( ! _imageLayer ) {
    1.25          _imageLayer = [[CALayer alloc] init];
    1.26          _imageLayer.contentsGravity = @"resizeAspect";
    1.27 +        _imageLayer.masksToBounds = YES;
    1.28          [self addSublayer: _imageLayer];
    1.29          [_imageLayer release];
    1.30      }
    1.31 -    _imageLayer.frame = CGRectInset(self.bounds, scale*.1, scale*.1);
    1.32 +    _imageLayer.frame = CGRectInset(self.bounds, outerDiameter-diameter, outerDiameter-diameter);
    1.33 +    _imageLayer.cornerRadius = diameter/2;
    1.34      _imageLayer.contents = (id) image;
    1.35 -    self.cornerRadius = scale/2;
    1.36 +    self.cornerRadius = outerDiameter/2;
    1.37      self.borderWidth = 3;
    1.38      self.borderColor = kTranslucentLightGrayColor;
    1.39      self.imageName = nil;