-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4759c15
Showing
18 changed files
with
1,535 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.mode1v3 | ||
*.pbxuser | ||
*.perspectivev3 | ||
*.xcworkspace | ||
xcuserdata |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?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>English</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIconFile</key> | ||
<string></string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.samsoffes.clock</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundlePackageType</key> | ||
<string>BNDL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright © 2014 Sam Soffes. All rights reserved.</string> | ||
<key>NSPrincipalClass</key> | ||
<string>ClockView</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// | ||
// Prefix header | ||
// | ||
// The contents of this file are implicitly included at the beginning of every source file. | ||
// | ||
|
||
#ifdef __OBJC__ | ||
#import <Cocoa/Cocoa.h> | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// ClockView.h | ||
// Clock | ||
// | ||
// Created by Sam Soffes on 3/8/14. | ||
// Copyright (c) 2014 Sam Soffes. All rights reserved. | ||
// | ||
|
||
#import <ScreenSaver/ScreenSaver.h> | ||
|
||
@interface ClockView : ScreenSaverView | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// | ||
// ClockView.m | ||
// Clock | ||
// | ||
// Created by Sam Soffes on 3/8/14. | ||
// Copyright (c) 2014 Sam Soffes. All rights reserved. | ||
// | ||
|
||
#import "ClockView.h" | ||
|
||
@implementation ClockView | ||
|
||
- (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview { | ||
if ((self = [super initWithFrame:frame isPreview:isPreview])) { | ||
[self setAnimationTimeInterval:1.0 / 30.0]; | ||
} | ||
return self; | ||
} | ||
|
||
|
||
- (void)startAnimation { | ||
[super startAnimation]; | ||
} | ||
|
||
|
||
- (void)stopAnimation { | ||
[super stopAnimation]; | ||
} | ||
|
||
|
||
- (void)drawRect:(NSRect)rect { | ||
[super drawRect:rect]; | ||
|
||
CGSize size = rect.size; | ||
|
||
[[NSColor blackColor] setFill]; | ||
[NSBezierPath fillRect:rect]; | ||
|
||
// NSDate *date = [NSDate date]; | ||
|
||
[[NSColor colorWithCalibratedWhite:1.0f alpha:0.2f] setStroke]; | ||
|
||
CGFloat clockSize = MIN(size.width, size.height) * 0.5; | ||
CGRect frame = CGRectMake(roundf((size.width - clockSize) / 2.0f), roundf((size.height - clockSize) / 2.0f), clockSize, clockSize); | ||
NSBezierPath *path = [NSBezierPath bezierPathWithOvalInRect:frame]; | ||
path.lineWidth = 4.0f; | ||
[path stroke]; | ||
|
||
CGPoint center = CGPointMake(CGRectGetMidX(frame), CGRectGetMidY(frame)); | ||
NSDateComponents *comps = [[NSCalendar currentCalendar] components:NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:[NSDate date]]; | ||
|
||
// Seconds | ||
[[NSColor whiteColor] setStroke]; | ||
path = [NSBezierPath bezierPath]; | ||
[path moveToPoint:center]; | ||
CGFloat angle = -(M_PI * 2.0f * (CGFloat)comps.second / 60.0f) + M_PI_2; | ||
CGFloat l = clockSize * 0.5f; | ||
CGPoint point = CGPointMake(center.x + cosf(angle) * l, center.y + sinf(angle) * l); | ||
[path lineToPoint:point]; | ||
path.lineWidth = 1.0f; | ||
[path stroke]; | ||
|
||
// Minutes | ||
[[NSColor colorWithCalibratedWhite:1.0f alpha:0.7f] setStroke]; | ||
path = [NSBezierPath bezierPath]; | ||
[path moveToPoint:center]; | ||
angle = -(M_PI * 2.0f * (CGFloat)comps.minute / 60.0f) + M_PI_2; | ||
l = clockSize * 0.45f; | ||
point = CGPointMake(center.x + cosf(angle) * l, center.y + sinf(angle) * l); | ||
[path lineToPoint:point]; | ||
path.lineWidth = 3.0f; | ||
[path stroke]; | ||
|
||
// Hours | ||
// [[NSColor colorWithCalibratedWhite:1.0f alpha:0.2f] setStroke]; | ||
path = [NSBezierPath bezierPath]; | ||
[path moveToPoint:center]; | ||
angle = -(M_PI * 2.0f * ((CGFloat)comps.hour + ((CGFloat)comps.minute / 60.0f)) / 12.0f) + M_PI_2; | ||
l = clockSize * 0.4f; | ||
point = CGPointMake(center.x + cosf(angle) * l, center.y + sinf(angle) * l); | ||
[path lineToPoint:point]; | ||
path.lineWidth = 5.0f; | ||
[path stroke]; | ||
} | ||
|
||
|
||
- (void)animateOneFrame { | ||
[self setNeedsDisplay:YES]; | ||
} | ||
|
||
|
||
- (BOOL)hasConfigureSheet { | ||
return NO; | ||
} | ||
|
||
- (NSWindow *)configureSheet { | ||
return nil; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* Localized versions of Info.plist keys */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// AppDelegate.h | ||
// ClockTest | ||
// | ||
// Created by Sam Soffes on 3/8/14. | ||
// Copyright (c) 2014 Sam Soffes. All rights reserved. | ||
// | ||
|
||
@class ClockView; | ||
|
||
@interface AppDelegate : NSObject <NSApplicationDelegate> | ||
|
||
@property (assign) IBOutlet NSWindow *window; | ||
@property IBOutlet ClockView *clockView; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// AppDelegate.m | ||
// ClockTest | ||
// | ||
// Created by Sam Soffes on 3/8/14. | ||
// Copyright (c) 2014 Sam Soffes. All rights reserved. | ||
// | ||
|
||
#import "AppDelegate.h" | ||
#import "ClockView.h" | ||
|
||
@implementation AppDelegate | ||
|
||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { | ||
[self.clockView startAnimation]; | ||
[NSTimer scheduledTimerWithTimeInterval:[self.clockView animationTimeInterval] target:self.clockView selector:@selector(animateOneFrame) userInfo:nil repeats:YES]; | ||
} | ||
|
||
@end |
Oops, something went wrong.