Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add color-command * add color-feature to the readme; add example * bugfix redraw * restructure for the color-command * bugfix failed travis build: UIColor->MTColor
- Loading branch information
Showing
14 changed files
with
246 additions
and
5 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
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
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
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
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
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
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
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
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 @@ | ||
// | ||
// NSColor+HexString.h | ||
// iosMath | ||
// | ||
// Created by Markus Sähn on 21/03/2017. | ||
// | ||
// | ||
|
||
#include <TargetConditionals.h> | ||
|
||
#if !TARGET_OS_IPHONE | ||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface NSColor (HexString) | ||
|
||
+ (NSColor *)colorFromHexString:(NSString *)hexString; | ||
|
||
@end | ||
#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,35 @@ | ||
// | ||
// NSColor+HexString.m | ||
// iosMath | ||
// | ||
// Created by Markus Sähn on 21/03/2017. | ||
// | ||
// | ||
|
||
#import "NSColor+HexString.h" | ||
|
||
#if !TARGET_OS_IPHONE | ||
@implementation NSColor (HexString) | ||
|
||
+ (NSColor *)colorFromHexString:(NSString *)hexString { | ||
if ([hexString isEqualToString:@""]) { | ||
return nil; | ||
} | ||
|
||
if ([hexString characterAtIndex:0] != '#') { | ||
return nil; | ||
} | ||
|
||
unsigned rgbValue = 0; | ||
|
||
NSScanner *scanner = [NSScanner scannerWithString:hexString]; | ||
if ([hexString characterAtIndex:0] == '#') { | ||
[scanner setScanLocation:1]; | ||
} | ||
|
||
[scanner scanHexInt:&rgbValue]; | ||
return [NSColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0]; | ||
} | ||
|
||
@end | ||
#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,16 @@ | ||
// | ||
// UIColor+HexString.h | ||
// iosMath | ||
// | ||
// Created by Markus Sähn on 21/03/2017. | ||
// | ||
// | ||
|
||
#if TARGET_OS_IPHONE | ||
|
||
@interface UIColor (HexString) | ||
|
||
+ (UIColor *)colorFromHexString:(NSString *)hexString; | ||
|
||
@end | ||
#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,36 @@ | ||
// | ||
// UIColor+HexString.m | ||
// iosMath | ||
// | ||
// Created by Markus Sähn on 21/03/2017. | ||
// | ||
// | ||
|
||
#import "UIColor+HexString.h" | ||
|
||
#if TARGET_OS_IPHONE | ||
|
||
@implementation UIColor (HexString) | ||
|
||
+ (UIColor *)colorFromHexString:(NSString *)hexString { | ||
if ([hexString isEqualToString:@""]) { | ||
return nil; | ||
} | ||
|
||
if ([hexString characterAtIndex:0] != '#') { | ||
return nil; | ||
} | ||
|
||
unsigned rgbValue = 0; | ||
|
||
NSScanner *scanner = [NSScanner scannerWithString:hexString]; | ||
if ([hexString characterAtIndex:0] == '#') { | ||
[scanner setScanLocation:1]; | ||
} | ||
|
||
[scanner scanHexInt:&rgbValue]; | ||
return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0]; | ||
} | ||
|
||
@end | ||
#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
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