Skip to content
This repository
Newer
Older
100644 99 lines (88 sloc) 2.942 kb
d6a27879 »
2011-01-16 Added new files
1 //
2 // CGUtils.m
3 // CoreTextExtensions
4 //
5 // Created by Oliver Drobnik on 1/16/11.
6 // Copyright 2011 Drobnik.com. All rights reserved.
7 //
8
9 #import "CGUtils.h"
10
11
1bf64de6 »
2011-09-05 replaced own rounded rect with UIBezierPath
12 // deprecated: use bezierPathWithRoundedRect instead
d6a27879 »
2011-01-16 Added new files
13
1bf64de6 »
2011-09-05 replaced own rounded rect with UIBezierPath
14 //CGPathRef newPathForRoundedRect(CGRect rect, CGFloat cornerRadius, BOOL roundTopCorners, BOOL roundBottomCorners)
15 //
16 //{
17 // CGMutablePathRef retPath = CGPathCreateMutable();
18 //
19 // CGRect innerRect = CGRectInset(rect, cornerRadius, cornerRadius);
20 //
21 // CGFloat inside_right = innerRect.origin.x + innerRect.size.width;
22 // CGFloat outside_right = rect.origin.x + rect.size.width;
23 // CGFloat inside_bottom = innerRect.origin.y + innerRect.size.height;
24 // CGFloat outside_bottom = rect.origin.y + rect.size.height;
25 //
26 // CGFloat inside_top = innerRect.origin.y;
27 // CGFloat outside_top = rect.origin.y;
28 // CGFloat outside_left = rect.origin.x;
29 //
30 //
31 // if (roundTopCorners)
32 // {
33 // CGPathMoveToPoint(retPath, NULL, innerRect.origin.x, outside_top);
34 // CGPathAddLineToPoint(retPath, NULL, inside_right, outside_top);
35 //
36 // CGPathAddArcToPoint(retPath, NULL, outside_right, outside_top, outside_right, inside_top, cornerRadius);
37 // }
38 // else
39 // {
40 // CGPathMoveToPoint(retPath, NULL, outside_left, outside_top);
41 // CGPathAddLineToPoint(retPath, NULL, outside_right, outside_top);
42 //
43 // }
44 //
45 // if (roundBottomCorners)
46 // {
47 // CGPathAddLineToPoint(retPath, NULL, outside_right, inside_bottom);
48 // CGPathAddArcToPoint(retPath, NULL, outside_right, outside_bottom, inside_right, outside_bottom, cornerRadius);
49 //
50 // CGPathAddLineToPoint(retPath, NULL, innerRect.origin.x, outside_bottom);
51 // CGPathAddArcToPoint(retPath, NULL, outside_left, outside_bottom, outside_left, inside_bottom, cornerRadius);
52 // }
53 // else
54 // {
55 // CGPathAddLineToPoint(retPath, NULL, outside_right, outside_bottom);
56 // CGPathAddLineToPoint(retPath, NULL, outside_left, outside_bottom);
57 // }
58 //
59 //
60 //
61 // if (roundTopCorners)
62 // {
63 // CGPathAddLineToPoint(retPath, NULL, outside_left, inside_top);
64 // CGPathAddArcToPoint(retPath, NULL, outside_left, outside_top, innerRect.origin.x, outside_top, cornerRadius);
65 // }
66 // else
67 // {
68 // CGPathAddLineToPoint(retPath, NULL, rect.origin.x, outside_top);
69 //
70 // }
71 //
72 //
73 // CGPathCloseSubpath(retPath);
74 //
75 // return retPath;
76 //}
d6a27879 »
2011-01-16 Added new files
77
c54be85d »
2012-05-28 Modifications to avoid conflict with DTFoundation
78 CGSize sizeThatFitsKeepingAspectRatio2(CGSize originalSize, CGSize sizeToFit)
67693c76 »
2011-01-19 Added support for VIDEO Tag.
79 {
d0907105 »
2011-05-09 Don't adjust size if already fitting.
80 if (originalSize.width <= sizeToFit.width && originalSize.height <= sizeToFit.height)
81 {
82 return originalSize;
83 }
84
67693c76 »
2011-01-19 Added support for VIDEO Tag.
85 CGFloat necessaryZoomWidth = sizeToFit.width / originalSize.width;
86 CGFloat necessaryZoomHeight = sizeToFit.height / originalSize.height;
87
88 CGFloat smallerZoom = MIN(necessaryZoomWidth, necessaryZoomHeight);
89
90 CGSize scaledSize = CGSizeMake(roundf(originalSize.width*smallerZoom), roundf(originalSize.height*smallerZoom));
d0907105 »
2011-05-09 Don't adjust size if already fitting.
91
67693c76 »
2011-01-19 Added support for VIDEO Tag.
92 return scaledSize;
93 }
3021ccc0 »
2011-04-13 faster way to find glyph next to point
94
95
96 CGPoint CGRectCenter(CGRect rect)
97 {
7528d115 » jonsterling
2011-06-25 Normalized indentation (tabs)
98 return (CGPoint){ CGRectGetMidX(rect), CGRectGetMidY(rect) };
3021ccc0 »
2011-04-13 faster way to find glyph next to point
99 }
Something went wrong with that request. Please try again.