Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ealeksandrov committed Jan 8, 2014
0 parents commit f7752d3
Show file tree
Hide file tree
Showing 24 changed files with 1,862 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .gitignore
@@ -0,0 +1,31 @@
#OS noise
profile
[Tt]humbs.db
*.DS_Store
*~
*.swp
*.out
*.bak*
*.lock

#Other CSM
.hg
.svn
CVS

#Xcode noise
*.log
*~.nib
*.moved-aside
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
*.xcworkspace/*
!*.xcworkspace/contents.xcworkspacedata
!xcshareddata

#Project files
[Bb]uild/
DerivedData/

#CocoaPods
Pods
19 changes: 19 additions & 0 deletions LICENSE
@@ -0,0 +1,19 @@
Copyright (c) 2013 Evgeny Aleksandrov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
15 changes: 15 additions & 0 deletions NSBezierPath+IOS7RoundedRect/NSBezierPath+IOS7RoundedRect.h
@@ -0,0 +1,15 @@
//
// NSBezierPath+IOS7RoundedRect.h
//
// Created by Matej Dunik on 11/12/13.
// Copyright (c) 2013 PixelCut. All rights reserved except as below:
// This code is provided as-is, without warranty of any kind. You may use it in your projects as you wish.
//

#import <Cocoa/Cocoa.h>

@interface NSBezierPath (IOS7RoundedRect)

+ (NSBezierPath*)bezierPathWithIOS7RoundedRect: (NSRect)rect cornerRadius: (CGFloat)radius;

@end
52 changes: 52 additions & 0 deletions NSBezierPath+IOS7RoundedRect/NSBezierPath+IOS7RoundedRect.m
@@ -0,0 +1,52 @@
//
// NSBezierPath+IOS7RoundedRect.m
//
// Created by Matej Dunik on 11/12/13.
// Copyright (c) 2013 PixelCut. All rights reserved except as below:
// This code is provided as-is, without warranty of any kind. You may use it in your projects as you wish.
//

#import "NSBezierPath+IOS7RoundedRect.h"

@implementation NSBezierPath (IOS7RoundedRect)

#define TOP_LEFT(X, Y) NSMakePoint(rect.origin.x + X * limitedRadius, rect.origin.y + Y * limitedRadius)
#define TOP_RIGHT(X, Y) NSMakePoint(rect.origin.x + rect.size.width - X * limitedRadius, rect.origin.y + Y * limitedRadius)
#define BOTTOM_RIGHT(X, Y) NSMakePoint(rect.origin.x + rect.size.width - X * limitedRadius, rect.origin.y + rect.size.height - Y * limitedRadius)
#define BOTTOM_LEFT(X, Y) NSMakePoint(rect.origin.x + X * limitedRadius, rect.origin.y + rect.size.height - Y * limitedRadius)


+ (NSBezierPath*)bezierPathWithIOS7RoundedRect: (NSRect)rect cornerRadius: (CGFloat)radius;
{
NSBezierPath* path = NSBezierPath.bezierPath;
CGFloat limit = MIN(rect.size.width, rect.size.height) / 2 / 1.52866483;
CGFloat limitedRadius = MIN(radius, limit);

[path moveToPoint: TOP_LEFT(1.52866483, 0.00000000)];
[path lineToPoint: TOP_RIGHT(1.52866471, 0.00000000)];
[path curveToPoint: TOP_RIGHT(0.66993427, 0.06549600) controlPoint1: TOP_RIGHT(1.08849323, 0.00000000) controlPoint2: TOP_RIGHT(0.86840689, 0.00000000)];
[path lineToPoint: TOP_RIGHT(0.63149399, 0.07491100)];
[path curveToPoint: TOP_RIGHT(0.07491176, 0.63149399) controlPoint1: TOP_RIGHT(0.37282392, 0.16905899) controlPoint2: TOP_RIGHT(0.16906013, 0.37282401)];
[path curveToPoint: TOP_RIGHT(0.00000000, 1.52866483) controlPoint1: TOP_RIGHT(0.00000000, 0.86840701) controlPoint2: TOP_RIGHT(0.00000000, 1.08849299)];
[path lineToPoint: BOTTOM_RIGHT(0.00000000, 1.52866471)];
[path curveToPoint: BOTTOM_RIGHT(0.06549569, 0.66993493) controlPoint1: BOTTOM_RIGHT(0.00000000, 1.08849323) controlPoint2: BOTTOM_RIGHT(0.00000000, 0.86840689)];
[path lineToPoint: BOTTOM_RIGHT(0.07491111, 0.63149399)];
[path curveToPoint: BOTTOM_RIGHT(0.63149399, 0.07491111) controlPoint1: BOTTOM_RIGHT(0.16905883, 0.37282392) controlPoint2: BOTTOM_RIGHT(0.37282392, 0.16905883)];
[path curveToPoint: BOTTOM_RIGHT(1.52866471, 0.00000000) controlPoint1: BOTTOM_RIGHT(0.86840689, 0.00000000) controlPoint2: BOTTOM_RIGHT(1.08849323, 0.00000000)];
[path lineToPoint: BOTTOM_LEFT(1.52866483, 0.00000000)];
[path curveToPoint: BOTTOM_LEFT(0.66993397, 0.06549569) controlPoint1: BOTTOM_LEFT(1.08849299, 0.00000000) controlPoint2: BOTTOM_LEFT(0.86840701, 0.00000000)];
[path lineToPoint: BOTTOM_LEFT(0.63149399, 0.07491111)];
[path curveToPoint: BOTTOM_LEFT(0.07491100, 0.63149399) controlPoint1: BOTTOM_LEFT(0.37282401, 0.16905883) controlPoint2: BOTTOM_LEFT(0.16906001, 0.37282392)];
[path curveToPoint: BOTTOM_LEFT(0.00000000, 1.52866471) controlPoint1: BOTTOM_LEFT(0.00000000, 0.86840689) controlPoint2: BOTTOM_LEFT(0.00000000, 1.08849323)];
[path lineToPoint: TOP_LEFT(0.00000000, 1.52866483)];
[path curveToPoint: TOP_LEFT(0.06549600, 0.66993397) controlPoint1: TOP_LEFT(0.00000000, 1.08849299) controlPoint2: TOP_LEFT(0.00000000, 0.86840701)];
[path lineToPoint: TOP_LEFT(0.07491100, 0.63149399)];
[path curveToPoint: TOP_LEFT(0.63149399, 0.07491100) controlPoint1: TOP_LEFT(0.16906001, 0.37282401) controlPoint2: TOP_LEFT(0.37282401, 0.16906001)];
[path curveToPoint: TOP_LEFT(1.52866483, 0.00000000) controlPoint1: TOP_LEFT(0.86840701, 0.00000000) controlPoint2: TOP_LEFT(1.08849299, 0.00000000)];
[path closePath];
return path;
}

@end


0 comments on commit f7752d3

Please sign in to comment.