Skip to content
Browse files

: initial version

  • Loading branch information...
0 parents commit 7c78b1a97d663eef976697dd8ea4133677936454 @paiv committed Feb 12, 2012
Showing with 1,546 additions and 0 deletions.
  1. +48 −0 AngleGradient/AngleGradientLayer.h
  2. +198 −0 AngleGradient/AngleGradientLayer.m
  3. +48 −0 AngleGradientSample/AngleGradient/AngleGradientLayer.h
  4. +198 −0 AngleGradientSample/AngleGradient/AngleGradientLayer.m
  5. +337 −0 AngleGradientSample/AngleGradientSample.xcodeproj/project.pbxproj
  6. +7 −0 AngleGradientSample/AngleGradientSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  7. +40 −0 AngleGradientSample/AngleGradientSample/AngleGradientSample-Info.plist
  8. +14 −0 AngleGradientSample/AngleGradientSample/AngleGradientSample-Prefix.pch
  9. +14 −0 AngleGradientSample/AngleGradientSample/AppDelegate.h
  10. +75 −0 AngleGradientSample/AngleGradientSample/AppDelegate.m
  11. +10 −0 AngleGradientSample/AngleGradientSample/SampleController.h
  12. +127 −0 AngleGradientSample/AngleGradientSample/SampleController.m
  13. +10 −0 AngleGradientSample/AngleGradientSample/UserControl1.h
  14. +48 −0 AngleGradientSample/AngleGradientSample/UserControl1.m
  15. +10 −0 AngleGradientSample/AngleGradientSample/UserControl2.h
  16. +51 −0 AngleGradientSample/AngleGradientSample/UserControl2.m
  17. +10 −0 AngleGradientSample/AngleGradientSample/UserControl3.h
  18. +40 −0 AngleGradientSample/AngleGradientSample/UserControl3.m
  19. +11 −0 AngleGradientSample/AngleGradientSample/UserControl4.h
  20. +47 −0 AngleGradientSample/AngleGradientSample/UserControl4.m
  21. +10 −0 AngleGradientSample/AngleGradientSample/UserControl5.h
  22. +69 −0 AngleGradientSample/AngleGradientSample/UserControl5.m
  23. +11 −0 AngleGradientSample/AngleGradientSample/UserControl6.h
  24. +57 −0 AngleGradientSample/AngleGradientSample/UserControl6.m
  25. +2 −0 AngleGradientSample/AngleGradientSample/en.lproj/InfoPlist.strings
  26. +17 −0 AngleGradientSample/AngleGradientSample/main.m
  27. +37 −0 README.textile
  28. BIN screenshot.png
48 AngleGradient/AngleGradientLayer.h
@@ -0,0 +1,48 @@
+//
+// The MIT License (MIT)
+//
+// Copyright (C) 2012 Pavel Ivashkov
+//
+// 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.
+//
+//
+// AngleGradientLayer.h
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+#import <QuartzCore/QuartzCore.h>
+
+
+@interface AngleGradientLayer : CALayer
+
+/* The array of CGColorRef objects defining the color of each gradient
+ * stop. Defaults to nil. */
+
+@property(copy) NSArray *colors;
+
+/* An optional array of NSNumber objects defining the location of each
+ * gradient stop as a value in the range [0,1]. The values must be
+ * monotonically increasing. If a nil array is given, the stops are
+ * assumed to spread uniformly across the [0,1] range. When rendered,
+ * the colors are mapped to the output colorspace before being
+ * interpolated. Defaults to nil. */
+
+@property(copy) NSArray *locations;
+
+@end
198 AngleGradient/AngleGradientLayer.m
@@ -0,0 +1,198 @@
+//
+// The MIT License (MIT)
+//
+// Copyright (C) 2012 Pavel Ivashkov
+//
+// 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.
+//
+//
+// AngleGradientLayer.m
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+#import "AngleGradientLayer.h"
+
+#define byte unsigned char
+#define uint unsigned int
+#define F2CC(x) ((byte)(255 * x))
+#define RGBAF(r,g,b,a) (F2CC(r) << 24 | F2CC(g) << 16 | F2CC(b) << 8 | F2CC(a))
+#define RGBA(r,g,b,a) ((byte)r << 24 | (byte)g << 16 | (byte)b << 8 | (byte)a)
+#define RGBA_R(c) ((uint)c >> 24 & 255)
+#define RGBA_G(c) ((uint)c >> 16 & 255)
+#define RGBA_B(c) ((uint)c >> 8 & 255)
+#define RGBA_A(c) ((uint)c >> 0 & 255)
+
+@interface AngleGradientLayer()
+
+- (CGImageRef)newImageGradientInRect:(CGRect)rect;
+
+@end
+
+
+static void angleGradient(byte* data, int w, int h, int* colors, int colorCount, float* locations, int locationCount);
+
+
+@implementation AngleGradientLayer
+
+@synthesize colors = _colors;
+@synthesize locations = _locations;
+
+- (id)init
+{
+ if (!(self = [super init]))
+ return nil;
+
+ self.needsDisplayOnBoundsChange = YES;
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [_colors release];
+ [_locations release];
+ [super dealloc];
+}
+
+- (void)drawInContext:(CGContextRef)ctx
+{
+ CGContextSetFillColorWithColor(ctx, self.backgroundColor);
+ CGRect rect = CGContextGetClipBoundingBox(ctx);
+ CGContextFillRect(ctx, rect);
+
+ CGImageRef img = [self newImageGradientInRect:rect];
+ CGContextDrawImage(ctx, rect, img);
+ CGImageRelease(img);
+}
+
+- (CGImageRef)newImageGradientInRect:(CGRect)rect
+{
+ int w = CGRectGetWidth(rect);
+ int h = CGRectGetHeight(rect);
+ int bitsPerComponent = 8;
+ int bpp = 4 * bitsPerComponent / 8;
+ int byteCount = w * h * bpp;
+
+ int colorCount = self.colors.count;
+ int locationCount = 0;
+ int* colors = NULL;
+ float* locations = NULL;
+
+ if (colorCount > 0) {
+ colors = calloc(colorCount, bpp);
+ int *p = colors;
+ for (id cg in self.colors) {
+ float r, g, b, a;
+ UIColor *c = [[UIColor alloc] initWithCGColor:(CGColorRef)cg];
+ if (![c getRed:&r green:&g blue:&b alpha:&a]) {
+ if (![c getWhite:&r alpha:&a]) {
+ [c release];
+ continue;
+ }
+ g = b = r;
+ }
+ [c release];
+ *p++ = RGBAF(r, g, b, a);
+ }
+ }
+ if (self.locations.count > 0 && self.locations.count == colorCount) {
+ locationCount = self.locations.count;
+ locations = calloc(locationCount, sizeof(locations[0]));
+ float *p = locations;
+ for (NSNumber *n in self.locations) {
+ *p++ = [n floatValue];
+ }
+ }
+
+ byte* data = malloc(byteCount);
+ angleGradient(data, w, h, colors, colorCount, locations, locationCount);
+
+ if (colors) free(colors);
+ if (locations) free(locations);
+
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Little;
+ CGContextRef ctx = CGBitmapContextCreate(data, w, h, bitsPerComponent, w * bpp, colorSpace, bitmapInfo);
+ CGColorSpaceRelease(colorSpace);
+ CGImageRef img = CGBitmapContextCreateImage(ctx);
+ CGContextRelease(ctx);
+ free(data);
+ return img;
+}
+
+@end
+
+static inline byte blerp(byte a, byte b, float w)
+{
+ return a + w * (b - a);
+}
+static inline int lerp(int a, int b, float w)
+{
+ return RGBA(blerp(RGBA_R(a), RGBA_R(b), w),
+ blerp(RGBA_G(a), RGBA_G(b), w),
+ blerp(RGBA_B(a), RGBA_B(b), w),
+ blerp(RGBA_A(a), RGBA_A(b), w));
+}
+
+void angleGradient(byte* data, int w, int h, int* colors, int colorCount, float* locations, int locationCount)
+{
+ if (colorCount < 1) return;
+ if (locationCount > 0 && locationCount != colorCount) return;
+
+ int* p = (int*)data;
+ float centerX = (float)w / 2;
+ float centerY = (float)h / 2;
+
+ for (int y = 0; y < h; y++)
+ for (int x = 0; x < w; x++) {
+ float dirX = x - centerX;
+ float dirY = y - centerY;
+ float angle = atan2f(dirY, dirX);
+ if (dirY < 0) angle += 2 * M_PI;
+ angle /= 2 * M_PI;
+
+ int index = 0, nextIndex = 0;
+ float t = 0;
+
+ if (locationCount > 0) {
+ for (index = locationCount - 1; index >= 0; index--) {
+ if (angle >= locations[index]) {
+ break;
+ }
+ }
+ if (index >= locationCount) index = locationCount - 1;
+ nextIndex = index + 1;
+ if (nextIndex >= locationCount) nextIndex = locationCount - 1;
+ float ld = locations[nextIndex] - locations[index];
+ t = ld <= 0 ? 0 : (angle - locations[index]) / ld;
+ }
+ else {
+ t = angle * (colorCount - 1);
+ index = t;
+ t -= index;
+ nextIndex = index + 1;
+ if (nextIndex >= colorCount) nextIndex = colorCount - 1;
+ }
+
+ int lc = colors[index];
+ int rc = colors[nextIndex];
+ int color = lerp(lc, rc, t);
+ *p++ = color;
+ }
+}
48 AngleGradientSample/AngleGradient/AngleGradientLayer.h
@@ -0,0 +1,48 @@
+//
+// The MIT License (MIT)
+//
+// Copyright (C) 2012 Pavel Ivashkov
+//
+// 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.
+//
+//
+// AngleGradientLayer.h
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+#import <QuartzCore/QuartzCore.h>
+
+
+@interface AngleGradientLayer : CALayer
+
+/* The array of CGColorRef objects defining the color of each gradient
+ * stop. Defaults to nil. */
+
+@property(copy) NSArray *colors;
+
+/* An optional array of NSNumber objects defining the location of each
+ * gradient stop as a value in the range [0,1]. The values must be
+ * monotonically increasing. If a nil array is given, the stops are
+ * assumed to spread uniformly across the [0,1] range. When rendered,
+ * the colors are mapped to the output colorspace before being
+ * interpolated. Defaults to nil. */
+
+@property(copy) NSArray *locations;
+
+@end
198 AngleGradientSample/AngleGradient/AngleGradientLayer.m
@@ -0,0 +1,198 @@
+//
+// The MIT License (MIT)
+//
+// Copyright (C) 2012 Pavel Ivashkov
+//
+// 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.
+//
+//
+// AngleGradientLayer.m
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+#import "AngleGradientLayer.h"
+
+#define byte unsigned char
+#define uint unsigned int
+#define F2CC(x) ((byte)(255 * x))
+#define RGBAF(r,g,b,a) (F2CC(r) << 24 | F2CC(g) << 16 | F2CC(b) << 8 | F2CC(a))
+#define RGBA(r,g,b,a) ((byte)r << 24 | (byte)g << 16 | (byte)b << 8 | (byte)a)
+#define RGBA_R(c) ((uint)c >> 24 & 255)
+#define RGBA_G(c) ((uint)c >> 16 & 255)
+#define RGBA_B(c) ((uint)c >> 8 & 255)
+#define RGBA_A(c) ((uint)c >> 0 & 255)
+
+@interface AngleGradientLayer()
+
+- (CGImageRef)newImageGradientInRect:(CGRect)rect;
+
+@end
+
+
+static void angleGradient(byte* data, int w, int h, int* colors, int colorCount, float* locations, int locationCount);
+
+
+@implementation AngleGradientLayer
+
+@synthesize colors = _colors;
+@synthesize locations = _locations;
+
+- (id)init
+{
+ if (!(self = [super init]))
+ return nil;
+
+ self.needsDisplayOnBoundsChange = YES;
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [_colors release];
+ [_locations release];
+ [super dealloc];
+}
+
+- (void)drawInContext:(CGContextRef)ctx
+{
+ CGContextSetFillColorWithColor(ctx, self.backgroundColor);
+ CGRect rect = CGContextGetClipBoundingBox(ctx);
+ CGContextFillRect(ctx, rect);
+
+ CGImageRef img = [self newImageGradientInRect:rect];
+ CGContextDrawImage(ctx, rect, img);
+ CGImageRelease(img);
+}
+
+- (CGImageRef)newImageGradientInRect:(CGRect)rect
+{
+ int w = CGRectGetWidth(rect);
+ int h = CGRectGetHeight(rect);
+ int bitsPerComponent = 8;
+ int bpp = 4 * bitsPerComponent / 8;
+ int byteCount = w * h * bpp;
+
+ int colorCount = self.colors.count;
+ int locationCount = 0;
+ int* colors = NULL;
+ float* locations = NULL;
+
+ if (colorCount > 0) {
+ colors = calloc(colorCount, bpp);
+ int *p = colors;
+ for (id cg in self.colors) {
+ float r, g, b, a;
+ UIColor *c = [[UIColor alloc] initWithCGColor:(CGColorRef)cg];
+ if (![c getRed:&r green:&g blue:&b alpha:&a]) {
+ if (![c getWhite:&r alpha:&a]) {
+ [c release];
+ continue;
+ }
+ g = b = r;
+ }
+ [c release];
+ *p++ = RGBAF(r, g, b, a);
+ }
+ }
+ if (self.locations.count > 0 && self.locations.count == colorCount) {
+ locationCount = self.locations.count;
+ locations = calloc(locationCount, sizeof(locations[0]));
+ float *p = locations;
+ for (NSNumber *n in self.locations) {
+ *p++ = [n floatValue];
+ }
+ }
+
+ byte* data = malloc(byteCount);
+ angleGradient(data, w, h, colors, colorCount, locations, locationCount);
+
+ if (colors) free(colors);
+ if (locations) free(locations);
+
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Little;
+ CGContextRef ctx = CGBitmapContextCreate(data, w, h, bitsPerComponent, w * bpp, colorSpace, bitmapInfo);
+ CGColorSpaceRelease(colorSpace);
+ CGImageRef img = CGBitmapContextCreateImage(ctx);
+ CGContextRelease(ctx);
+ free(data);
+ return img;
+}
+
+@end
+
+static inline byte blerp(byte a, byte b, float w)
+{
+ return a + w * (b - a);
+}
+static inline int lerp(int a, int b, float w)
+{
+ return RGBA(blerp(RGBA_R(a), RGBA_R(b), w),
+ blerp(RGBA_G(a), RGBA_G(b), w),
+ blerp(RGBA_B(a), RGBA_B(b), w),
+ blerp(RGBA_A(a), RGBA_A(b), w));
+}
+
+void angleGradient(byte* data, int w, int h, int* colors, int colorCount, float* locations, int locationCount)
+{
+ if (colorCount < 1) return;
+ if (locationCount > 0 && locationCount != colorCount) return;
+
+ int* p = (int*)data;
+ float centerX = (float)w / 2;
+ float centerY = (float)h / 2;
+
+ for (int y = 0; y < h; y++)
+ for (int x = 0; x < w; x++) {
+ float dirX = x - centerX;
+ float dirY = y - centerY;
+ float angle = atan2f(dirY, dirX);
+ if (dirY < 0) angle += 2 * M_PI;
+ angle /= 2 * M_PI;
+
+ int index = 0, nextIndex = 0;
+ float t = 0;
+
+ if (locationCount > 0) {
+ for (index = locationCount - 1; index >= 0; index--) {
+ if (angle >= locations[index]) {
+ break;
+ }
+ }
+ if (index >= locationCount) index = locationCount - 1;
+ nextIndex = index + 1;
+ if (nextIndex >= locationCount) nextIndex = locationCount - 1;
+ float ld = locations[nextIndex] - locations[index];
+ t = ld <= 0 ? 0 : (angle - locations[index]) / ld;
+ }
+ else {
+ t = angle * (colorCount - 1);
+ index = t;
+ t -= index;
+ nextIndex = index + 1;
+ if (nextIndex >= colorCount) nextIndex = colorCount - 1;
+ }
+
+ int lc = colors[index];
+ int rc = colors[nextIndex];
+ int color = lerp(lc, rc, t);
+ *p++ = color;
+ }
+}
337 AngleGradientSample/AngleGradientSample.xcodeproj/project.pbxproj
@@ -0,0 +1,337 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ C40F40D614E71A7B00566C8F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C40F40D514E71A7B00566C8F /* UIKit.framework */; };
+ C40F40D814E71A7B00566C8F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C40F40D714E71A7B00566C8F /* Foundation.framework */; };
+ C40F40DA14E71A7B00566C8F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C40F40D914E71A7B00566C8F /* CoreGraphics.framework */; };
+ C40F40E014E71A7B00566C8F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C40F40DE14E71A7B00566C8F /* InfoPlist.strings */; };
+ C40F40E214E71A7B00566C8F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F40E114E71A7B00566C8F /* main.m */; };
+ C40F40E614E71A7B00566C8F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F40E514E71A7B00566C8F /* AppDelegate.m */; };
+ C40F40F314E71B3800566C8F /* SampleController.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F40F214E71B3800566C8F /* SampleController.m */; };
+ C40F40F514E71C1600566C8F /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C40F40F414E71C1600566C8F /* QuartzCore.framework */; };
+ C40F40F814E71D0700566C8F /* UserControl1.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F40F714E71D0700566C8F /* UserControl1.m */; };
+ C40F410214E75C9A00566C8F /* UserControl2.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F410114E75C9900566C8F /* UserControl2.m */; };
+ C40F410514E761FD00566C8F /* UserControl3.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F410414E761FD00566C8F /* UserControl3.m */; };
+ C40F410814E7663100566C8F /* UserControl4.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F410714E7663100566C8F /* UserControl4.m */; };
+ C40F410C14E7693400566C8F /* UserControl5.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F410B14E7693400566C8F /* UserControl5.m */; };
+ C49C2FB314E7E9D200E36420 /* UserControl6.m in Sources */ = {isa = PBXBuildFile; fileRef = C49C2FB214E7E9D200E36420 /* UserControl6.m */; };
+ C49C2FB714E811EE00E36420 /* AngleGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = C49C2FB614E811EE00E36420 /* AngleGradientLayer.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ C40F40D114E71A7B00566C8F /* AngleGradientSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AngleGradientSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ C40F40D514E71A7B00566C8F /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ C40F40D714E71A7B00566C8F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ C40F40D914E71A7B00566C8F /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ C40F40DD14E71A7B00566C8F /* AngleGradientSample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AngleGradientSample-Info.plist"; sourceTree = "<group>"; };
+ C40F40DF14E71A7B00566C8F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ C40F40E114E71A7B00566C8F /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ C40F40E314E71A7B00566C8F /* AngleGradientSample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AngleGradientSample-Prefix.pch"; sourceTree = "<group>"; };
+ C40F40E414E71A7B00566C8F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
+ C40F40E514E71A7B00566C8F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+ C40F40F114E71B3800566C8F /* SampleController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SampleController.h; sourceTree = "<group>"; };
+ C40F40F214E71B3800566C8F /* SampleController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SampleController.m; sourceTree = "<group>"; };
+ C40F40F414E71C1600566C8F /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+ C40F40F614E71D0700566C8F /* UserControl1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl1.h; sourceTree = "<group>"; };
+ C40F40F714E71D0700566C8F /* UserControl1.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl1.m; sourceTree = "<group>"; };
+ C40F410014E75C9900566C8F /* UserControl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl2.h; sourceTree = "<group>"; };
+ C40F410114E75C9900566C8F /* UserControl2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl2.m; sourceTree = "<group>"; };
+ C40F410314E761FD00566C8F /* UserControl3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl3.h; sourceTree = "<group>"; };
+ C40F410414E761FD00566C8F /* UserControl3.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl3.m; sourceTree = "<group>"; };
+ C40F410614E7663100566C8F /* UserControl4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl4.h; sourceTree = "<group>"; };
+ C40F410714E7663100566C8F /* UserControl4.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl4.m; sourceTree = "<group>"; };
+ C40F410A14E7693400566C8F /* UserControl5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl5.h; sourceTree = "<group>"; };
+ C40F410B14E7693400566C8F /* UserControl5.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl5.m; sourceTree = "<group>"; };
+ C49C2FB114E7E9D200E36420 /* UserControl6.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl6.h; sourceTree = "<group>"; };
+ C49C2FB214E7E9D200E36420 /* UserControl6.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl6.m; sourceTree = "<group>"; };
+ C49C2FB514E811EE00E36420 /* AngleGradientLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AngleGradientLayer.h; sourceTree = "<group>"; };
+ C49C2FB614E811EE00E36420 /* AngleGradientLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AngleGradientLayer.m; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ C40F40CE14E71A7A00566C8F /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ C40F40D614E71A7B00566C8F /* UIKit.framework in Frameworks */,
+ C40F40D814E71A7B00566C8F /* Foundation.framework in Frameworks */,
+ C40F40DA14E71A7B00566C8F /* CoreGraphics.framework in Frameworks */,
+ C40F40F514E71C1600566C8F /* QuartzCore.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ C40F40C614E71A7A00566C8F = {
+ isa = PBXGroup;
+ children = (
+ C49C2FB414E811EE00E36420 /* AngleGradient */,
+ C40F40DB14E71A7B00566C8F /* AngleGradientSample */,
+ C40F40D414E71A7B00566C8F /* Frameworks */,
+ C40F40D214E71A7B00566C8F /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ C40F40D214E71A7B00566C8F /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ C40F40D114E71A7B00566C8F /* AngleGradientSample.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ C40F40D414E71A7B00566C8F /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ C40F40D514E71A7B00566C8F /* UIKit.framework */,
+ C40F40D714E71A7B00566C8F /* Foundation.framework */,
+ C40F40D914E71A7B00566C8F /* CoreGraphics.framework */,
+ C40F40F414E71C1600566C8F /* QuartzCore.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ C40F40DB14E71A7B00566C8F /* AngleGradientSample */ = {
+ isa = PBXGroup;
+ children = (
+ C40F40E414E71A7B00566C8F /* AppDelegate.h */,
+ C40F40E514E71A7B00566C8F /* AppDelegate.m */,
+ C40F40F114E71B3800566C8F /* SampleController.h */,
+ C40F40F214E71B3800566C8F /* SampleController.m */,
+ C40F410914E766F300566C8F /* Samples */,
+ C40F40DC14E71A7B00566C8F /* Supporting Files */,
+ );
+ path = AngleGradientSample;
+ sourceTree = "<group>";
+ };
+ C40F40DC14E71A7B00566C8F /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ C40F40DD14E71A7B00566C8F /* AngleGradientSample-Info.plist */,
+ C40F40DE14E71A7B00566C8F /* InfoPlist.strings */,
+ C40F40E114E71A7B00566C8F /* main.m */,
+ C40F40E314E71A7B00566C8F /* AngleGradientSample-Prefix.pch */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ C40F410914E766F300566C8F /* Samples */ = {
+ isa = PBXGroup;
+ children = (
+ C40F40F614E71D0700566C8F /* UserControl1.h */,
+ C40F40F714E71D0700566C8F /* UserControl1.m */,
+ C40F410014E75C9900566C8F /* UserControl2.h */,
+ C40F410114E75C9900566C8F /* UserControl2.m */,
+ C40F410314E761FD00566C8F /* UserControl3.h */,
+ C40F410414E761FD00566C8F /* UserControl3.m */,
+ C40F410614E7663100566C8F /* UserControl4.h */,
+ C40F410714E7663100566C8F /* UserControl4.m */,
+ C40F410A14E7693400566C8F /* UserControl5.h */,
+ C40F410B14E7693400566C8F /* UserControl5.m */,
+ C49C2FB114E7E9D200E36420 /* UserControl6.h */,
+ C49C2FB214E7E9D200E36420 /* UserControl6.m */,
+ );
+ name = Samples;
+ sourceTree = "<group>";
+ };
+ C49C2FB414E811EE00E36420 /* AngleGradient */ = {
+ isa = PBXGroup;
+ children = (
+ C49C2FB514E811EE00E36420 /* AngleGradientLayer.h */,
+ C49C2FB614E811EE00E36420 /* AngleGradientLayer.m */,
+ );
+ path = AngleGradient;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ C40F40D014E71A7A00566C8F /* AngleGradientSample */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = C40F40E914E71A7B00566C8F /* Build configuration list for PBXNativeTarget "AngleGradientSample" */;
+ buildPhases = (
+ C40F40CD14E71A7A00566C8F /* Sources */,
+ C40F40CE14E71A7A00566C8F /* Frameworks */,
+ C40F40CF14E71A7A00566C8F /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = AngleGradientSample;
+ productName = AngleGradientSample;
+ productReference = C40F40D114E71A7B00566C8F /* AngleGradientSample.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ C40F40C814E71A7A00566C8F /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ ORGANIZATIONNAME = "Archer Software";
+ };
+ buildConfigurationList = C40F40CB14E71A7A00566C8F /* Build configuration list for PBXProject "AngleGradientSample" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = C40F40C614E71A7A00566C8F;
+ productRefGroup = C40F40D214E71A7B00566C8F /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ C40F40D014E71A7A00566C8F /* AngleGradientSample */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ C40F40CF14E71A7A00566C8F /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ C40F40E014E71A7B00566C8F /* InfoPlist.strings in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ C40F40CD14E71A7A00566C8F /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ C40F40E214E71A7B00566C8F /* main.m in Sources */,
+ C40F40E614E71A7B00566C8F /* AppDelegate.m in Sources */,
+ C40F40F314E71B3800566C8F /* SampleController.m in Sources */,
+ C40F40F814E71D0700566C8F /* UserControl1.m in Sources */,
+ C40F410214E75C9A00566C8F /* UserControl2.m in Sources */,
+ C40F410514E761FD00566C8F /* UserControl3.m in Sources */,
+ C40F410814E7663100566C8F /* UserControl4.m in Sources */,
+ C40F410C14E7693400566C8F /* UserControl5.m in Sources */,
+ C49C2FB314E7E9D200E36420 /* UserControl6.m in Sources */,
+ C49C2FB714E811EE00E36420 /* AngleGradientLayer.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ C40F40DE14E71A7B00566C8F /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ C40F40DF14E71A7B00566C8F /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ C40F40E714E71A7B00566C8F /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = (
+ armv6,
+ armv7,
+ );
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 3.2;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ C40F40E814E71A7B00566C8F /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = (
+ armv6,
+ armv7,
+ );
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 3.2;
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ C40F40EA14E71A7B00566C8F /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "AngleGradientSample/AngleGradientSample-Prefix.pch";
+ INFOPLIST_FILE = "AngleGradientSample/AngleGradientSample-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ C40F40EB14E71A7B00566C8F /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "AngleGradientSample/AngleGradientSample-Prefix.pch";
+ INFOPLIST_FILE = "AngleGradientSample/AngleGradientSample-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ C40F40CB14E71A7A00566C8F /* Build configuration list for PBXProject "AngleGradientSample" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ C40F40E714E71A7B00566C8F /* Debug */,
+ C40F40E814E71A7B00566C8F /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ C40F40E914E71A7B00566C8F /* Build configuration list for PBXNativeTarget "AngleGradientSample" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ C40F40EA14E71A7B00566C8F /* Debug */,
+ C40F40EB14E71A7B00566C8F /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = C40F40C814E71A7A00566C8F /* Project object */;
+}
7 ...GradientSample/AngleGradientSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:AngleGradientSample.xcodeproj">
+ </FileRef>
+</Workspace>
40 AngleGradientSample/AngleGradientSample/AngleGradientSample-Info.plist
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFiles</key>
+ <array/>
+ <key>CFBundleIdentifier</key>
+ <string>paiv.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
14 AngleGradientSample/AngleGradientSample/AngleGradientSample-Prefix.pch
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'AngleGradientSample' target in the 'AngleGradientSample' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_3_0
+#warning "This project uses features only available in iOS SDK 3.0 and later."
+#endif
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+#endif
14 AngleGradientSample/AngleGradientSample/AppDelegate.h
@@ -0,0 +1,14 @@
+//
+// AppDelegate.h
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-11.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@end
75 AngleGradientSample/AngleGradientSample/AppDelegate.m
@@ -0,0 +1,75 @@
+//
+// AppDelegate.m
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-11.
+//
+
+#import "AppDelegate.h"
+#import "SampleController.h"
+
+
+@implementation AppDelegate
+
+@synthesize window = _window;
+
+- (void)dealloc
+{
+ [_window release];
+ [super dealloc];
+}
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
+ // Override point for customization after application launch.
+ self.window.backgroundColor = [UIColor whiteColor];
+
+ SampleController *vc = [[SampleController alloc] init];
+ [self.window setRootViewController:vc];
+ [vc release];
+
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application
+{
+ /*
+ Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+ */
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ /*
+ Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+ */
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application
+{
+ /*
+ Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+ */
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application
+{
+ /*
+ Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+ */
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ /*
+ Called when the application is about to terminate.
+ Save data if appropriate.
+ See also applicationDidEnterBackground:.
+ */
+}
+
+@end
10 AngleGradientSample/AngleGradientSample/SampleController.h
@@ -0,0 +1,10 @@
+//
+// SampleController.h
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-11.
+//
+
+@interface SampleController : UIViewController
+
+@end
127 AngleGradientSample/AngleGradientSample/SampleController.m
@@ -0,0 +1,127 @@
+//
+// SampleController.m
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-11.
+//
+
+#import <QuartzCore/QuartzCore.h>
+#import "SampleController.h"
+#import "UserControl1.h"
+#import "UserControl2.h"
+#import "UserControl3.h"
+#import "UserControl4.h"
+#import "UserControl5.h"
+#import "UserControl6.h"
+
+
+@interface SampleController()
+
+@property(retain, nonatomic) UIControl *uc5;
+
+@end
+
+
+@implementation SampleController
+
+@synthesize uc5 = _uc5;
+
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ if (!(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
+ return nil;
+ return self;
+}
+
+- (void)dealloc
+{
+ [_uc5 release];
+ [super dealloc];
+}
+
+- (void)didReceiveMemoryWarning
+{
+ // Releases the view if it doesn't have a superview.
+ [super didReceiveMemoryWarning];
+
+ // Release any cached data, images, etc that aren't in use.
+}
+
+- (void)handleDragInside:(UIControl *)control withEvent:(UIEvent *)event
+{
+ [control.superview bringSubviewToFront:control];
+ control.center = [[[event allTouches] anyObject] locationInView:control.superview];
+}
+
+#pragma mark - View lifecycle
+
+// Implement loadView to create a view hierarchy programmatically, without using a nib.
+- (void)loadView
+{
+ CGRect rect = [UIScreen mainScreen].applicationFrame;
+ UIScrollView *v = [[UIScrollView alloc] initWithFrame:rect];
+ v.backgroundColor = [UIColor magentaColor];
+
+ UserControl1 *uc1 = [[UserControl1 alloc] initWithFrame:v.bounds];
+ [v addSubview:uc1];
+ [uc1 release];
+
+ UserControl2 *uc2 = [[UserControl2 alloc] initWithFrame:CGRectMake(5, 5, 88, 88)];
+ [v addSubview:uc2];
+ [uc2 release];
+
+ UserControl3 *uc3 = [[UserControl3 alloc] initWithFrame:CGRectMake(155, 95, 66, 66)];
+ [v addSubview:uc3];
+ [uc3 release];
+
+ UserControl4 *uc4 = [[UserControl4 alloc] initWithFrame:CGRectMake(190, 305, 120, 120)];
+ [v addSubview:uc4];
+ [uc4 release];
+
+ _uc5 = [[UserControl5 alloc] initWithFrame:CGRectMake(15, 335, 100, 100)];
+ [v addSubview:_uc5];
+
+ UserControl6 *uc6 = [[UserControl6 alloc] initWithFrame:CGRectMake(-10, 225, 135, 135)];
+ [v addSubview:uc6];
+ [uc6 release];
+
+ v.contentSize = uc1.frame.size;
+ self.view = v;
+ [v release];
+}
+
+// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ for (UIView *v in self.view.subviews) {
+ if (![v isKindOfClass:[UIControl class]]) continue;
+ [(UIControl *)v addTarget:self action:@selector(handleDragInside:withEvent:) forControlEvents:UIControlEventTouchDragInside];
+ }
+
+ CABasicAnimation * spin = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
+ spin.duration = 1;
+ spin.toValue = [NSNumber numberWithFloat:M_PI];
+ spin.cumulative = YES;
+ spin.repeatCount = MAXFLOAT;
+ [self.uc5.layer addAnimation:spin forKey:@"spin"];
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+ // e.g. self.myOutlet = nil;
+
+ self.uc5 = nil;
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ // Return YES for supported orientations
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
+}
+
+@end
10 AngleGradientSample/AngleGradientSample/UserControl1.h
@@ -0,0 +1,10 @@
+//
+// UserControl1.h
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+@interface UserControl1 : UIView
+
+@end
48 AngleGradientSample/AngleGradientSample/UserControl1.m
@@ -0,0 +1,48 @@
+//
+// UserControl1.m
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+#import "AngleGradientLayer.h"
+#import "UserControl1.h"
+
+@implementation UserControl1
+
++ (Class)layerClass
+{
+ return [AngleGradientLayer class];
+}
+
+- (id)initWithFrame:(CGRect)frame
+{
+ if (!(self = [super initWithFrame:frame]))
+ return nil;
+
+ self.backgroundColor = [UIColor whiteColor];
+
+ NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:16];
+ NSMutableArray *locations = [[NSMutableArray alloc] initWithCapacity:16];
+
+ for (int i = 0; i < 5; i++) {
+ [colors addObject:(id)[UIColor colorWithRed:252/255.0 green:253/255.0 blue:203/255.0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:250/255.0 green:96/255.0 blue:53/255.0 alpha:1].CGColor];
+ [locations addObject:[NSNumber numberWithFloat:(0.2 * i)]];
+ [locations addObject:[NSNumber numberWithFloat:(0.2 * i + 0.16)]];
+ }
+ [colors addObject:(id)[UIColor colorWithRed:252/255.0 green:253/255.0 blue:203/255.0 alpha:1].CGColor];
+ [locations addObject:[NSNumber numberWithInt:1]];
+
+ AngleGradientLayer *l = (AngleGradientLayer *)self.layer;
+ l.colors = colors;
+ l.locations = locations;
+
+ [colors release];
+ [locations release];
+
+ return self;
+}
+
+
+@end
10 AngleGradientSample/AngleGradientSample/UserControl2.h
@@ -0,0 +1,10 @@
+//
+// UserControl2.h
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+@interface UserControl2 : UIControl
+
+@end
51 AngleGradientSample/AngleGradientSample/UserControl2.m
@@ -0,0 +1,51 @@
+//
+// UserControl2.m
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+#import "AngleGradientLayer.h"
+#import "UserControl2.h"
+
+
+@implementation UserControl2
+
++ (Class)layerClass
+{
+ return [AngleGradientLayer class];
+}
+
+- (id)initWithFrame:(CGRect)frame
+{
+ if (!(self = [super initWithFrame:frame]))
+ return nil;
+
+ self.backgroundColor = [UIColor whiteColor];
+
+ NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:16];
+
+ [colors addObject:(id)[UIColor colorWithWhite:0.65 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithWhite:0.9 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithWhite:0.75 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithWhite:0.35 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithWhite:0.75 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithWhite:0.9 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithWhite:0.75 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithWhite:0.35 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithWhite:0.55 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithWhite:0.65 alpha:1].CGColor];
+
+ AngleGradientLayer *l = (AngleGradientLayer *)self.layer;
+ l.colors = colors;
+ [colors release];
+
+ l.cornerRadius = CGRectGetWidth(self.bounds) / 2;
+ self.clipsToBounds = YES;
+ l.borderColor = [UIColor colorWithWhite:0.55 alpha:1].CGColor;
+ l.borderWidth = 1;
+
+ return self;
+}
+
+@end
10 AngleGradientSample/AngleGradientSample/UserControl3.h
@@ -0,0 +1,10 @@
+//
+// UserControl3.h
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+@interface UserControl3 : UIControl
+
+@end
40 AngleGradientSample/AngleGradientSample/UserControl3.m
@@ -0,0 +1,40 @@
+//
+// UserControl3.m
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+#import "AngleGradientLayer.h"
+#import "UserControl3.h"
+
+
+@implementation UserControl3
+
++ (Class)layerClass
+{
+ return [AngleGradientLayer class];
+}
+
+- (id)initWithFrame:(CGRect)frame
+{
+ if (!(self = [super initWithFrame:frame]))
+ return nil;
+
+ self.backgroundColor = [UIColor whiteColor];
+
+ NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:16];
+
+ [colors addObject:(id)[UIColor colorWithRed:0 green:0 blue:0.5 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0.4 alpha:1].CGColor];
+
+ AngleGradientLayer *l = (AngleGradientLayer *)self.layer;
+ l.colors = colors;
+ [colors release];
+
+ self.transform = CGAffineTransformMakeRotation(0.75 * M_PI);
+
+ return self;
+}
+
+@end
11 AngleGradientSample/AngleGradientSample/UserControl4.h
@@ -0,0 +1,11 @@
+//
+// UserControl4.h
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+
+@interface UserControl4 : UIControl
+
+@end
47 AngleGradientSample/AngleGradientSample/UserControl4.m
@@ -0,0 +1,47 @@
+//
+// UserControl4.m
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+#import "AngleGradientLayer.h"
+#import "UserControl4.h"
+
+
+@implementation UserControl4
+
++ (Class)layerClass
+{
+ return [AngleGradientLayer class];
+}
+
+- (id)initWithFrame:(CGRect)frame
+{
+ if (!(self = [super initWithFrame:frame]))
+ return nil;
+
+ self.backgroundColor = [UIColor whiteColor];
+
+ NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:4];
+
+ [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:1 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:0 green:0 blue:1 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:1 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:0 alpha:1].CGColor];
+
+ AngleGradientLayer *l = (AngleGradientLayer *)self.layer;
+ l.colors = colors;
+ [colors release];
+
+ l.cornerRadius = CGRectGetWidth(self.bounds) / 2;
+ self.clipsToBounds = YES;
+ self.transform = CGAffineTransformMakeRotation(-M_PI_2);
+
+ return self;
+}
+
+@end
10 AngleGradientSample/AngleGradientSample/UserControl5.h
@@ -0,0 +1,10 @@
+//
+// UserControl5.h
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+@interface UserControl5 : UIControl
+
+@end
69 AngleGradientSample/AngleGradientSample/UserControl5.m
@@ -0,0 +1,69 @@
+//
+// UserControl5.m
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+#import "AngleGradientLayer.h"
+#import "UserControl5.h"
+
+
+@implementation UserControl5
+
++ (Class)layerClass
+{
+ return [AngleGradientLayer class];
+}
+
+- (id)initWithFrame:(CGRect)frame
+{
+ if (!(self = [super initWithFrame:frame]))
+ return nil;
+
+ self.backgroundColor = [UIColor whiteColor];
+
+ NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:4];
+ NSMutableArray *locations = [[NSMutableArray alloc] initWithCapacity:16];
+
+ [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:1 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:1 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:0 green:0 blue:1 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:0 green:0 blue:1 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:1 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:1 alpha:1].CGColor];
+
+ [locations addObject:[NSNumber numberWithInt:0]];
+ [locations addObject:[NSNumber numberWithFloat:0.158]];
+ [locations addObject:[NSNumber numberWithFloat:0.16]];
+ [locations addObject:[NSNumber numberWithFloat:0.328]];
+ [locations addObject:[NSNumber numberWithFloat:0.33]];
+ [locations addObject:[NSNumber numberWithFloat:0.498]];
+ [locations addObject:[NSNumber numberWithFloat:0.50]];
+ [locations addObject:[NSNumber numberWithFloat:0.658]];
+ [locations addObject:[NSNumber numberWithFloat:0.66]];
+ [locations addObject:[NSNumber numberWithFloat:0.838]];
+ [locations addObject:[NSNumber numberWithFloat:0.84]];
+ [locations addObject:[NSNumber numberWithInt:1]];
+
+ AngleGradientLayer *l = (AngleGradientLayer *)self.layer;
+ l.colors = colors;
+ l.locations = locations;
+
+ [colors release];
+ [locations release];
+
+ l.cornerRadius = CGRectGetWidth(self.bounds) / 2;
+ self.clipsToBounds = YES;
+// self.transform = CGAffineTransformMakeRotation(0.25 * M_PI_2);
+
+ return self;
+}
+
+@end
11 AngleGradientSample/AngleGradientSample/UserControl6.h
@@ -0,0 +1,11 @@
+//
+// UserControl6.h
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+// Copyright (c) 2012 Archer Software. All rights reserved.
+//
+
+@interface UserControl6 : UIControl
+
+@end
57 AngleGradientSample/AngleGradientSample/UserControl6.m
@@ -0,0 +1,57 @@
+//
+// UserControl6.m
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-12.
+//
+
+#import "AngleGradientLayer.h"
+#import "UserControl6.h"
+
+
+@implementation UserControl6
+
++ (Class)layerClass
+{
+ return [AngleGradientLayer class];
+}
+
+- (id)initWithFrame:(CGRect)frame
+{
+ if (!(self = [super initWithFrame:frame]))
+ return nil;
+
+ self.backgroundColor = [UIColor whiteColor];
+
+ NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:4];
+ NSMutableArray *locations = [[NSMutableArray alloc] initWithCapacity:16];
+
+ for (int i = 0; i < 6; i++) {
+ [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:100/255.0 blue:25/255.0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:100/255.0 blue:25/255.0 alpha:1].CGColor];
+ }
+ [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor];
+ [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor];
+
+ const float fa[] = { 0, 4.0, 5, 29.0, 30, 49.0, 50, 74.0, 75, 104.0, 105, 134.0,
+ 135, 189.0, 190, 219.0, 220, 254.0, 255, 279.0, 280, 314.0, 315, 339.0, 340, 360 };
+ for (int i = 0; i < sizeof(fa)/sizeof(fa[0]); i++)
+ [locations addObject:[NSNumber numberWithFloat:fa[i] / 360.0]];
+
+ AngleGradientLayer *l = (AngleGradientLayer *)self.layer;
+ l.colors = colors;
+ l.locations = locations;
+
+ [colors release];
+ [locations release];
+
+// l.cornerRadius = CGRectGetWidth(self.bounds) / 2;
+// self.clipsToBounds = YES;
+ self.transform = CGAffineTransformMakeRotation(0.25 * M_PI_2);
+
+ return self;
+}
+
+@end
2 AngleGradientSample/AngleGradientSample/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
17 AngleGradientSample/AngleGradientSample/main.m
@@ -0,0 +1,17 @@
+//
+// main.m
+// AngleGradientSample
+//
+// Created by Pavel Ivashkov on 2012-02-11.
+//
+
+#import <UIKit/UIKit.h>
+
+#import "AppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
+ }
+}
37 README.textile
@@ -0,0 +1,37 @@
+h2. AngleGradientLayer
+
+*AngleGradientLayer* is a *CALayer* implementation of angle gradient.
+
+!screenshot.png!
+
+h2. Sample usage with UIView
+
+(See demo project for more.)
+
+bc.. #import "AngleGradientLayer.h"
+
+@interface MyView : UIView
+@end
+
+@implementation MyView
+
++ (Class)layerClass
+{
+ return [AngleGradientLayer class];
+}
+
+- (id)initWithFrame:(CGRect)frame
+{
+ if (!(self = [super initWithFrame:frame]))
+ return nil;
+
+ AngleGradientLayer *l = (AngleGradientLayer *)self.layer;
+ l.colors = [NSArray arrayWithObjects:
+ (id)[UIColor colorWithRed:0 green:0 blue:0.5 alpha:1].CGColor,
+ (id)[UIColor colorWithRed:1 green:1 blue:0.4 alpha:1].CGColor,
+ nil];
+
+ return self;
+}
+
+@end
BIN screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7c78b1a

Please sign in to comment.
Something went wrong with that request. Please try again.