Created
January 26, 2012 18:27
-
-
Save steveatinfincia/1684204 to your computer and use it in GitHub Desktop.
Signal bars drawn in code from Mi-Fi Monitor
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
//where the lowest point on the bar begins in the rect | |
float baseline = 3.0f; | |
// the vertical stopping point of each bar if it isn't "filled" | |
float cutoff = 5.0f; | |
// offset everything from the left by this amount | |
float offset = 1.0f; | |
//width of each bar | |
float width = 3.0f; | |
//vertical height of each additional bar segment | |
float barsegment = 3.0f; | |
// puts each "filled" bar up a little higher by a set amount so they look clearly different (especially matters for the first bar) | |
float booster = 4.0f; | |
// spacing between the bars | |
float spacing = 5.0f; | |
NSBezierPath *path = [[NSBezierPath alloc] init]; | |
[path setLineWidth:width]; | |
//first bar | |
[path moveToPoint:NSMakePoint((width + spacing * 0.0f) + offset , baseline)]; | |
[path lineToPoint:NSMakePoint((width + spacing * 0.0f) + offset , ( self.siglevel >= 1 ? booster + (barsegment * 1) : cutoff) )]; | |
//second bar | |
[path moveToPoint:NSMakePoint((width + spacing * 1.0f) + offset , baseline)]; | |
[path lineToPoint:NSMakePoint((width + spacing * 1.0f) + offset , ( self.siglevel >= 2 ? booster + (barsegment * 2) : cutoff) )]; | |
//third bar | |
[path moveToPoint:NSMakePoint((width + spacing * 2.0f) + offset , baseline)]; | |
[path lineToPoint:NSMakePoint((width + spacing * 2.0f) + offset , ( self.siglevel >= 3 ? booster + (barsegment * 3) : cutoff) )]; | |
//fourth bar | |
[path moveToPoint:NSMakePoint((width + spacing * 3.0f) + offset , baseline)]; | |
[path lineToPoint:NSMakePoint((width + spacing * 3.0f) + offset , ( self.siglevel >= 4 ? booster + (barsegment * 4) : cutoff) )]; | |
//fifth bar | |
[path moveToPoint:NSMakePoint((width + spacing * 4.0f) + offset , baseline)]; | |
[path lineToPoint:NSMakePoint((width + spacing * 4.0f) + offset , ( self.siglevel >= 5 ? booster + (barsegment * 5) : cutoff) )]; | |
if (isMenuVisible) { | |
[[NSColor whiteColor] set]; | |
} | |
else { | |
if (self.siglevel < 1) { | |
[[NSColor redColor] set]; | |
} | |
else { | |
[[NSColor colorWithCalibratedWhite:0.1 alpha:0.9] set]; | |
} | |
} | |
[path stroke]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment