Use IconMaker to create retina icon.

This commit is contained in:
Lukhnos Liu 2012-09-04 00:52:13 -07:00
parent 6525894cb5
commit 176ecb74ff
4 changed files with 138 additions and 21 deletions

View File

@ -0,0 +1,13 @@
//
// BopomofoIconRenderView.h
// Lettuce
//
// Created by Lukhnos D. Liu on 9/3/12.
//
//
#import <Cocoa/Cocoa.h>
@interface BopomofoIconRenderView : NSView
@end

View File

@ -0,0 +1,56 @@
//
// BopomofoIconRenderView.m
// Lettuce
//
// Created by Lukhnos D. Liu on 9/3/12.
//
//
#import "BopomofoIconRenderView.h"
@implementation BopomofoIconRenderView
- (void)drawRect:(NSRect)dirtyRect
{
NSAffineTransform *transform = [NSAffineTransform transform];
[transform scaleBy:[self bounds].size.width / 16.0];
[transform concat];
NSRect boundsRect = NSMakeRect(0.0, 0.0, 16.0, 16.0);
if ([self bounds].size.width > 16.0) {
boundsRect.origin.x += 0.5;
}
boundsRect.size.width -= 1.0;
[NSGraphicsContext saveGraphicsState];
NSColor *darkGrayColor = [NSColor colorWithDeviceWhite:0.3 alpha:1.0];
[darkGrayColor setFill];
[[NSBezierPath bezierPathWithRoundedRect:boundsRect xRadius:2.0 yRadius:2.0] fill];
[NSGraphicsContext restoreGraphicsState];
NSInteger fontSize = ([self bounds].size.width > 16.0) ? 14.0 : 13.5;
NSString *text = @"ㄅ";
NSString *fontName = @"BiauKai";
NSColor *textColor = nil;
textColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0];
NSMutableDictionary *attrDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
textColor, NSForegroundColorAttributeName,
[NSFont fontWithName:fontName size:fontSize], NSFontAttributeName,
nil];
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:text attributes:attrDict];
NSRect textBounds = [attrString boundingRectWithSize:boundsRect.size options:NSStringDrawingUsesLineFragmentOrigin];
NSPoint textOrigin;
textOrigin.x = boundsRect.origin.x + (boundsRect.size.width - textBounds.size.width) / 2.0;
textOrigin.y = boundsRect.origin.y;
attrString = [[NSAttributedString alloc] initWithString:text attributes:attrDict];
[attrString drawAtPoint:textOrigin];
}
@end

View File

@ -71,8 +71,12 @@
faviconRenderView.selected = YES; faviconRenderView.selected = YES;
[faviconRenderView setNeedsDisplay:YES]; [faviconRenderView setNeedsDisplay:YES];
[self makeIconForObject:@"TISIconRendererView" size:NSMakeSize(16, 16) filename:@"/tmp/Bopomofo.tiff"]; // [self makeIconForObject:@"TISIconRendererView" size:NSMakeSize(16, 16) filename:@"/tmp/Bopomofo.tiff"];
[self makeIconForObject:selectedTISIconRendererView size:NSMakeSize(16, 16) filename:@"/tmp/BopomofoSelected.tiff"]; // [self makeIconForObject:selectedTISIconRendererView size:NSMakeSize(16, 16) filename:@"/tmp/BopomofoSelected.tiff"];
[self makeIconForObject:@"BopomofoIconRenderView" size:NSMakeSize(16, 16) filename:@"/tmp/Bopomofo.tiff"];
[self makeIconForObject:@"BopomofoIconRenderView" size:NSMakeSize(32, 32) filename:@"/tmp/Bopomofo@2x.tiff"];
[self makeIconForObject:@"BopomofoIconRenderView" size:NSMakeSize(16, 16) filename:@"/tmp/BopomofoSelected.tiff"];
[self makeIconForObject:faviconRenderView size:NSMakeSize(16, 16) filename:@"/tmp/BopomofoFavicon.tiff"]; [self makeIconForObject:faviconRenderView size:NSMakeSize(16, 16) filename:@"/tmp/BopomofoFavicon.tiff"];

View File

@ -2,22 +2,22 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data> <data>
<int key="IBDocument.SystemTarget">1070</int> <int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">11A2063</string> <string key="IBDocument.SystemVersion">11E53</string>
<string key="IBDocument.InterfaceBuilderVersion">1910</string> <string key="IBDocument.InterfaceBuilderVersion">2549</string>
<string key="IBDocument.AppKitVersion">1138.1</string> <string key="IBDocument.AppKitVersion">1138.47</string>
<string key="IBDocument.HIToolboxVersion">566.00</string> <string key="IBDocument.HIToolboxVersion">569.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions"> <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">1910</string> <string key="NS.object.0">2549</string>
</object> </object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies"> <object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>NSCustomObject</string>
<string>NSCustomView</string> <string>NSCustomView</string>
<string>NSWindowTemplate</string>
<string>NSView</string>
<string>NSMenu</string> <string>NSMenu</string>
<string>NSMenuItem</string> <string>NSMenuItem</string>
<string>NSCustomObject</string> <string>NSView</string>
<string>NSWindowTemplate</string>
</object> </object>
<object class="NSArray" key="IBDocument.PluginDependencies"> <object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@ -1337,13 +1337,22 @@
<reference key="NSNextKeyView" ref="249506468"/> <reference key="NSNextKeyView" ref="249506468"/>
<string key="NSClassName">TISIconRendererView</string> <string key="NSClassName">TISIconRendererView</string>
</object> </object>
<object class="NSCustomView" id="497031166">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{20, 188}, {16, 16}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="371291187"/>
<string key="NSClassName">BopomofoIconRenderView</string>
</object>
<object class="NSCustomView" id="371291187"> <object class="NSCustomView" id="371291187">
<reference key="NSNextResponder" ref="439893737"/> <reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int> <int key="NSvFlags">268</int>
<string key="NSFrame">{{44, 148}, {128, 128}}</string> <string key="NSFrame">{{44, 148}, {128, 128}}</string>
<reference key="NSSuperview" ref="439893737"/> <reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1011390326"/> <reference key="NSNextKeyView" ref="373465065"/>
<string key="NSClassName">AppIconRendererView</string> <string key="NSClassName">AppIconRendererView</string>
</object> </object>
<object class="NSCustomView" id="1011390326"> <object class="NSCustomView" id="1011390326">
@ -1352,6 +1361,7 @@
<string key="NSFrame">{{180, 20}, {256, 256}}</string> <string key="NSFrame">{{180, 20}, {256, 256}}</string>
<reference key="NSSuperview" ref="439893737"/> <reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSClassName">AppIconRendererView</string> <string key="NSClassName">AppIconRendererView</string>
</object> </object>
<object class="NSCustomView" id="249506468"> <object class="NSCustomView" id="249506468">
@ -1360,7 +1370,7 @@
<string key="NSFrame">{{20, 236}, {16, 16}}</string> <string key="NSFrame">{{20, 236}, {16, 16}}</string>
<reference key="NSSuperview" ref="439893737"/> <reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="371291187"/> <reference key="NSNextKeyView" ref="756090883"/>
<string key="NSClassName">TISIconRendererView</string> <string key="NSClassName">TISIconRendererView</string>
</object> </object>
<object class="NSCustomView" id="756090883"> <object class="NSCustomView" id="756090883">
@ -1369,8 +1379,18 @@
<string key="NSFrame">{{20, 212}, {16, 16}}</string> <string key="NSFrame">{{20, 212}, {16, 16}}</string>
<reference key="NSSuperview" ref="439893737"/> <reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="497031166"/>
<string key="NSClassName">TISIconRendererView</string> <string key="NSClassName">TISIconRendererView</string>
</object> </object>
<object class="NSCustomView" id="373465065">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{20, 108}, {32, 32}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1011390326"/>
<string key="NSClassName">BopomofoIconRenderView</string>
</object>
</object> </object>
<string key="NSFrameSize">{451, 296}</string> <string key="NSFrameSize">{451, 296}</string>
<reference key="NSSuperview"/> <reference key="NSSuperview"/>
@ -2649,6 +2669,8 @@
<reference ref="1011390326"/> <reference ref="1011390326"/>
<reference ref="249506468"/> <reference ref="249506468"/>
<reference ref="756090883"/> <reference ref="756090883"/>
<reference ref="497031166"/>
<reference ref="373465065"/>
</object> </object>
<reference key="parent" ref="972006081"/> <reference key="parent" ref="972006081"/>
</object> </object>
@ -3163,6 +3185,16 @@
<reference key="object" ref="756090883"/> <reference key="object" ref="756090883"/>
<reference key="parent" ref="439893737"/> <reference key="parent" ref="439893737"/>
</object> </object>
<object class="IBObjectRecord">
<int key="objectID">540</int>
<reference key="object" ref="497031166"/>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">541</int>
<reference key="object" ref="373465065"/>
<reference key="parent" ref="439893737"/>
</object>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="flattenedProperties"> <object class="NSMutableDictionary" key="flattenedProperties">
@ -3313,6 +3345,8 @@
<string>535.IBPluginDependency</string> <string>535.IBPluginDependency</string>
<string>536.IBPluginDependency</string> <string>536.IBPluginDependency</string>
<string>538.IBPluginDependency</string> <string>538.IBPluginDependency</string>
<string>540.IBPluginDependency</string>
<string>541.IBPluginDependency</string>
<string>56.IBPluginDependency</string> <string>56.IBPluginDependency</string>
<string>57.IBPluginDependency</string> <string>57.IBPluginDependency</string>
<string>58.IBPluginDependency</string> <string>58.IBPluginDependency</string>
@ -3329,7 +3363,7 @@
<string>83.IBPluginDependency</string> <string>83.IBPluginDependency</string>
<string>92.IBPluginDependency</string> <string>92.IBPluginDependency</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -3490,6 +3524,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="unlocalizedProperties"> <object class="NSMutableDictionary" key="unlocalizedProperties">
@ -3504,7 +3540,7 @@
<reference key="dict.values" ref="0"/> <reference key="dict.values" ref="0"/>
</object> </object>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">539</int> <int key="maxID">541</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions"> <object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -3517,6 +3553,14 @@
<string key="minorKey">./Classes/AppIconRendererView.h</string> <string key="minorKey">./Classes/AppIconRendererView.h</string>
</object> </object>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">BopomofoIconRenderView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/BopomofoIconRenderView.h</string>
</object>
</object>
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">IconMakerAppDelegate</string> <string key="className">IconMakerAppDelegate</string>
<string key="superclassName">NSObject</string> <string key="superclassName">NSObject</string>
@ -3528,7 +3572,7 @@
<string>selectedTISIconRendererView</string> <string>selectedTISIconRendererView</string>
<string>window</string> <string>window</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>TISIconRendererView</string> <string>TISIconRendererView</string>
<string>TISIconRendererView</string> <string>TISIconRendererView</string>
@ -3543,7 +3587,7 @@
<string>selectedTISIconRendererView</string> <string>selectedTISIconRendererView</string>
<string>window</string> <string>window</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo"> <object class="IBToOneOutletInfo">
<string key="name">faviconRenderView</string> <string key="name">faviconRenderView</string>
@ -3577,7 +3621,7 @@
<string>saveDocumentAs:</string> <string>saveDocumentAs:</string>
<string>saveDocumentTo:</string> <string>saveDocumentTo:</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string> <string>id</string>
<string>id</string> <string>id</string>
@ -3598,7 +3642,7 @@
<string>saveDocumentAs:</string> <string>saveDocumentAs:</string>
<string>saveDocumentTo:</string> <string>saveDocumentTo:</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo"> <object class="IBActionInfo">
<string key="name">printDocument:</string> <string key="name">printDocument:</string>
@ -3656,10 +3700,10 @@
<string>NSMenuCheckmark</string> <string>NSMenuCheckmark</string>
<string>NSMenuMixedState</string> <string>NSMenuMixedState</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>{9, 8}</string> <string>{11, 11}</string>
<string>{7, 2}</string> <string>{10, 3}</string>
</object> </object>
</object> </object>
</data> </data>