Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit d3518d98bd14c58f23d6ca0a9b0fcebc371a8ad9 1 parent 4ad28b1
Simon Whitaker authored
View
2  .gitignore
@@ -0,0 +1,2 @@
+xcuserdata
+.DS_Store
View
21 Second Conf 2011.xcodeproj/project.pbxproj
@@ -10,8 +10,8 @@
F48F4F41142DDBED004E8956 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F48F4F40142DDBED004E8956 /* Cocoa.framework */; };
F48F4F43142DDBED004E8956 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F48F4F42142DDBED004E8956 /* ScreenSaver.framework */; };
F48F4F4D142DDBED004E8956 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F48F4F4B142DDBED004E8956 /* InfoPlist.strings */; };
- F48F4F50142DDBED004E8956 /* Second_Conf_2011View.h in Headers */ = {isa = PBXBuildFile; fileRef = F48F4F4F142DDBED004E8956 /* Second_Conf_2011View.h */; };
- F48F4F52142DDBED004E8956 /* Second_Conf_2011View.m in Sources */ = {isa = PBXBuildFile; fileRef = F48F4F51142DDBED004E8956 /* Second_Conf_2011View.m */; };
+ F48F4F50142DDBED004E8956 /* SCScreenSaverView.h in Headers */ = {isa = PBXBuildFile; fileRef = F48F4F4F142DDBED004E8956 /* SCScreenSaverView.h */; };
+ F48F4F52142DDBED004E8956 /* SCScreenSaverView.m in Sources */ = {isa = PBXBuildFile; fileRef = F48F4F51142DDBED004E8956 /* SCScreenSaverView.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -21,11 +21,11 @@
F48F4F45142DDBED004E8956 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
F48F4F46142DDBED004E8956 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
F48F4F47142DDBED004E8956 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
- F48F4F4A142DDBED004E8956 /* Second Conf 2011-Info.plist */ = {isa = PBXFileReference; path = "Second Conf 2011-Info.plist"; sourceTree = "<group>"; };
+ F48F4F4A142DDBED004E8956 /* Second Conf 2011-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Second Conf 2011-Info.plist"; sourceTree = "<group>"; };
F48F4F4C142DDBED004E8956 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
- F48F4F4E142DDBED004E8956 /* Second Conf 2011-Prefix.pch */ = {isa = PBXFileReference; path = "Second Conf 2011-Prefix.pch"; sourceTree = "<group>"; };
- F48F4F4F142DDBED004E8956 /* Second_Conf_2011View.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Second_Conf_2011View.h; sourceTree = "<group>"; };
- F48F4F51142DDBED004E8956 /* Second_Conf_2011View.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Second_Conf_2011View.m; sourceTree = "<group>"; };
+ F48F4F4E142DDBED004E8956 /* Second Conf 2011-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Second Conf 2011-Prefix.pch"; sourceTree = "<group>"; };
+ F48F4F4F142DDBED004E8956 /* SCScreenSaverView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = SCScreenSaverView.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
+ F48F4F51142DDBED004E8956 /* SCScreenSaverView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = SCScreenSaverView.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -81,8 +81,8 @@
F48F4F48142DDBED004E8956 /* Second Conf 2011 */ = {
isa = PBXGroup;
children = (
- F48F4F4F142DDBED004E8956 /* Second_Conf_2011View.h */,
- F48F4F51142DDBED004E8956 /* Second_Conf_2011View.m */,
+ F48F4F4F142DDBED004E8956 /* SCScreenSaverView.h */,
+ F48F4F51142DDBED004E8956 /* SCScreenSaverView.m */,
F48F4F49142DDBED004E8956 /* Supporting Files */,
);
path = "Second Conf 2011";
@@ -105,7 +105,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
- F48F4F50142DDBED004E8956 /* Second_Conf_2011View.h in Headers */,
+ F48F4F50142DDBED004E8956 /* SCScreenSaverView.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -182,7 +182,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- F48F4F52142DDBED004E8956 /* Second_Conf_2011View.m in Sources */,
+ F48F4F52142DDBED004E8956 /* SCScreenSaverView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -290,6 +290,7 @@
F48F4F57142DDBED004E8956 /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
View
7 Second Conf 2011.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:Second Conf 2011.xcodeproj">
+ </FileRef>
+</Workspace>
View
16 Second Conf 2011/SCScreenSaverView.h
@@ -0,0 +1,16 @@
+//
+// SCScreenSaverView.h
+// Second Conf 2011
+//
+// Created by Simon Whitaker <simon@goosoftware.co.uk> on 24/09/2011.
+//
+
+#import <ScreenSaver/ScreenSaver.h>
+
+@interface SCScreenSaverView : ScreenSaverView
+
+@property (nonatomic) CGFloat angleOffsetRads;
+@property (nonatomic, retain) NSDate * lastFired;
+@property (nonatomic) NSInteger pulseChunk;
+@property (nonatomic, retain) NSDate * lastChangedChunkPulse;
+@end
View
210 Second Conf 2011/SCScreenSaverView.m
@@ -0,0 +1,210 @@
+//
+// SCScreenSaverView.m
+// Second Conf 2011
+//
+// Created by Simon Whitaker <simon@goosoftware.co.uk> on 24/09/2011.
+//
+
+#import "SCScreenSaverView.h"
+
+@interface SCSegment : NSObject
+
+// A simple class for representing a segment ("slice of pie") in the logo
+
+@property (nonatomic, retain) NSColor * color;
+@property (nonatomic) NSUInteger numberOfChunks;
+
++ (SCSegment*)segmentWithColor:(NSColor*)color
+ andNumberOfChunks:(NSUInteger)numberOfChunks;
+
+@end
+
+@implementation SCSegment
+
+@synthesize color=_color;
+@synthesize numberOfChunks=_numberOfChunks;
+
++ (SCSegment*)segmentWithColor:(NSColor*)color
+ andNumberOfChunks:(NSUInteger)numberOfChunks
+{
+ SCSegment *segment = [[SCSegment alloc] init];
+ segment.color = color;
+ segment.numberOfChunks = numberOfChunks;
+ return [segment autorelease];
+}
+
+@end
+
+@implementation SCScreenSaverView
+
+@synthesize angleOffsetRads=_angleOffsetRads;
+@synthesize lastFired=_lastFired;
+@synthesize pulseChunk=_pulseChunk;
+@synthesize lastChangedChunkPulse=_lastChangedChunkPulse;
+
+- (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
+{
+ self = [super initWithFrame:frame isPreview:isPreview];
+ if (self) {
+ self.angleOffsetRads = 0.0;
+ self.pulseChunk = 0;
+ self.lastChangedChunkPulse = [NSDate date];
+ [self setAnimationTimeInterval:1/30.0];
+ }
+ return self;
+}
+
+- (void)startAnimation
+{
+ [super startAnimation];
+}
+
+- (void)stopAnimation
+{
+ [super stopAnimation];
+}
+
+- (void)drawRect:(NSRect)rect
+{
+ [super drawRect:rect];
+
+ NSPoint center = NSMakePoint(rect.size.width / 2, rect.size.height / 2);
+
+ // What's the widest we can go?
+ CGFloat limit = center.x > center.y ? center.y : center.x;
+
+ // baseRadius is the radius of the inside of the inner-most chunks. Think of it
+ // as the radius of the black circle in the middle of the puzzle
+ CGFloat baseRadius = limit / 5.0;
+
+ // chunkWidth is the width ("thickness"?) of the chunks, i.e. the distance in
+ // pixels between the inner curve and the outer curve of a chunk.
+ CGFloat chunkWidth = baseRadius / 2.5;
+
+ // Declare the constants we'll need to draw the logo
+ static NSArray *Segments = nil;
+
+ if (Segments == nil) {
+ NSColor * orangeColor = [NSColor colorWithDeviceHue:0.06 saturation:1.0 brightness:1.0 alpha:1.0];
+ NSColor * grayColor = [NSColor colorWithDeviceHue:0.0 saturation:0.0 brightness:0.5 alpha:1.0];
+ NSColor * yellowColor = [NSColor colorWithDeviceHue:0.13 saturation:1.0 brightness:1.0 alpha:1.0];
+
+ Segments = [[NSArray alloc] initWithObjects:
+ [SCSegment segmentWithColor:yellowColor andNumberOfChunks:7],
+ [SCSegment segmentWithColor:grayColor andNumberOfChunks:2],
+ [SCSegment segmentWithColor:orangeColor andNumberOfChunks:7],
+ [SCSegment segmentWithColor:yellowColor andNumberOfChunks:2],
+ [SCSegment segmentWithColor:grayColor andNumberOfChunks:5],
+ [SCSegment segmentWithColor:orangeColor andNumberOfChunks:3],
+ [SCSegment segmentWithColor:yellowColor andNumberOfChunks:5],
+ [SCSegment segmentWithColor:orangeColor andNumberOfChunks:6],
+ [SCSegment segmentWithColor:grayColor andNumberOfChunks:7],
+ nil];
+ }
+
+ // Step through the segments. A segment is all the stuff between two radii. Or to
+ // put it another way, it's a slice of pie. Mmmm, pie! (Please don't confuse
+ // "Mmmm, pie!" with M_PI, for that way lies disaster.
+ for (NSUInteger i = 0; i < [Segments count]; i++) {
+ SCSegment *segment = [Segments objectAtIndex:i];
+ for (NSUInteger chunk = 0; chunk < segment.numberOfChunks; chunk++) {
+ CGFloat segmentArcRads = M_PI * 2 / 10.0;
+ CGFloat offsetRads = self.angleOffsetRads - 4 * segmentArcRads;
+
+ CGFloat startRads = segmentArcRads * i + offsetRads;
+ CGFloat endRads = startRads + segmentArcRads;
+ CGFloat insideRadius = baseRadius + chunkWidth * chunk;
+ CGFloat outsideRadius = insideRadius + chunkWidth;
+
+ CGPoint insideStart = NSMakePoint(center.x + insideRadius * sinf(startRads),
+ center.y + insideRadius * cosf(startRads));
+ CGPoint outsideStart = NSMakePoint(center.x + (outsideRadius) * sinf(startRads),
+ center.y + (outsideRadius) * cosf(startRads));
+ CGPoint insideEnd = NSMakePoint(center.x + (insideRadius) * sinf(endRads),
+ center.y + (insideRadius)* cosf(endRads));
+
+ NSBezierPath *aPath = [NSBezierPath bezierPath];
+ [aPath setLineWidth:chunkWidth / 10.0];
+
+ // Convert angles in radians that increase clockwise from 12 o'clock to
+ // angles in degrees that increase anticlockwise from 3 o'clock
+ CGFloat startDegrees = 90 - (startRads / M_PI * 180.0);
+ CGFloat endDegrees = 90 - (endRads / M_PI * 180.0);
+
+ [aPath moveToPoint:insideStart];
+ [aPath lineToPoint:outsideStart];
+ [aPath appendBezierPathWithArcWithCenter:center
+ radius:outsideRadius
+ startAngle:startDegrees
+ endAngle:endDegrees
+ clockwise:YES];
+ [aPath lineToPoint:insideEnd];
+ [aPath appendBezierPathWithArcWithCenter:center
+ radius:insideRadius
+ startAngle:endDegrees
+ endAngle:startDegrees
+ clockwise:NO];
+ if (chunk == self.pulseChunk) {
+ [[NSColor colorWithDeviceHue:segment.color.hueComponent
+ saturation:segment.color.saturationComponent
+ brightness:segment.color.brightnessComponent
+ alpha:0.1 + 0.1 * chunk] setFill];
+
+ }
+ else {
+ [segment.color setFill];
+ }
+
+ [aPath fill];
+
+ [[NSColor blackColor] setStroke];
+
+ [aPath stroke];
+ }
+ }
+ if (!self.isAnimating) {
+ [self startAnimation];
+ }
+}
+
+- (void)animateOneFrame
+{
+ static CGFloat RevsPerSecond = 1.0 / 60.0;
+ static NSTimeInterval PulseChunkChangeDelay = 0.1;
+ NSDate * now = [NSDate date];
+
+ if (self.lastFired == nil) {
+ self.lastFired = now;
+ self.angleOffsetRads = 0.0;
+ } else {
+ NSTimeInterval secondsSinceLastFire = [now timeIntervalSinceDate:self.lastFired];
+ CGFloat numRevolutions = RevsPerSecond * secondsSinceLastFire;
+ CGFloat angularIncrementRads = M_PI * 2 * numRevolutions;
+
+ self.angleOffsetRads = self.angleOffsetRads + angularIncrementRads;
+ self.lastFired = now;
+ }
+
+ if ([now timeIntervalSinceDate:self.lastChangedChunkPulse] > PulseChunkChangeDelay) {
+ self.lastChangedChunkPulse = now;
+ self.pulseChunk = (self.pulseChunk + 1) % 20;
+ }
+
+ if (self.angleOffsetRads > M_PI * 2) {
+ self.angleOffsetRads -= M_PI * 2;
+ }
+ self.needsDisplay = YES;
+ return;
+}
+
+- (BOOL)hasConfigureSheet
+{
+ return NO;
+}
+
+- (NSWindow*)configureSheet
+{
+ return nil;
+}
+
+@end
View
4 Second Conf 2011/Second Conf 2011-Info.plist
@@ -22,9 +22,7 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
- <key>NSHumanReadableCopyright</key>
- <string>Copyright © 2011 Goo Software Ltd. All rights reserved.</string>
<key>NSPrincipalClass</key>
- <string>Second_Conf_2011View</string>
+ <string>SCScreenSaverView</string>
</dict>
</plist>
View
13 Second Conf 2011/Second_Conf_2011View.h
@@ -1,13 +0,0 @@
-//
-// Second_Conf_2011View.h
-// Second Conf 2011
-//
-// Created by Simon Whitaker on 24/09/2011.
-// Copyright 2011 Goo Software Ltd. All rights reserved.
-//
-
-#import <ScreenSaver/ScreenSaver.h>
-
-@interface Second_Conf_2011View : ScreenSaverView
-
-@end
View
52 Second Conf 2011/Second_Conf_2011View.m
@@ -1,52 +0,0 @@
-//
-// Second_Conf_2011View.m
-// Second Conf 2011
-//
-// Created by Simon Whitaker on 24/09/2011.
-// Copyright 2011 Goo Software Ltd. All rights reserved.
-//
-
-#import "Second_Conf_2011View.h"
-
-@implementation Second_Conf_2011View
-
-- (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
-{
- self = [super initWithFrame:frame isPreview:isPreview];
- if (self) {
- [self setAnimationTimeInterval:1/30.0];
- }
- return self;
-}
-
-- (void)startAnimation
-{
- [super startAnimation];
-}
-
-- (void)stopAnimation
-{
- [super stopAnimation];
-}
-
-- (void)drawRect:(NSRect)rect
-{
- [super drawRect:rect];
-}
-
-- (void)animateOneFrame
-{
- return;
-}
-
-- (BOOL)hasConfigureSheet
-{
- return NO;
-}
-
-- (NSWindow*)configureSheet
-{
- return nil;
-}
-
-@end
Please sign in to comment.
Something went wrong with that request. Please try again.