Acorn and JSTalk

March 27th, 2010 by Chris

Last month when planning for exhibiting our iPhone apps at Macworld Expo, we decided to use the fabulous services at MOO to create promotional materials to hand out at the show. We wanted to have a a simple way for attendees to take something with them with as a reminder of our iPhone apps. We also needed a method to hand out iTunes App Store promotional codes that could be used to redeem copies after the attendees went home.

Moo’s MiniCards were very affordable and sized just right for our purposes:

Macworld MooCards Blog.png

They are sized small enough that its not a burden to carry around the conference. Not everyone at Macworld wants to load up a bag full of chotskies, schwag and product materials! We found the MiniCard’s appearance and quality really attracted the attention of attendees. Also, critical to our needs each card can have one side that con be printed with a separate image. Perfect for making individual cards each have a unique promo code.

Apple allots developers 50 promotional codes per version of their application. In total we had four versions of Postage plus, SnoGlobe and RoseGlobe that we wanted to make a full set of 50 moo cards with a promo code on the back for. That was 300 unique images we needed to make and upload! Certainly a tedious process at best.

Lucky for us, we had some automation magic in our toolchest thanks to Flying Meat’s image editor Acorn and Gus’s excellent new technology project JSTalk. While there are plenty of Mac OS graphics tools that support AppleScript for automation, I have to be completely honest here. Every time I try to use AppleScript I find myself struggling with the syntax and terminology. Frequently I just give up and do whatever I was trying to accomplish manually after banging my head on the keyboard for a few hours.

JSTalk exposes Cocoa frameworks and applications for scripting and automation using JavaScript. It also performs some preprocessor shenanigans so you can write JavaScript that looks a lot like Objective-C. Being an Objective-C programmer for a good number of years now, I find this absolutely charming. I don’t have to bootstrap myself into learning a new language, especially not some crazy english-language hybrid that demoralizes me for weeks at time after it beats me over the head with my apparent lack of basic English language literacy.

While Acorn has built-in support for JSTalk, Gus has made it easy for other applications to add support as well. JSTalk also allows other applications without support to be automated using the Script Bridge.

To create the backs for our MiniCards, we started with a the image of the layout of the back of the card. Brad left an empty spot for the text :

PostageMooCardsBack.png

Then I created a JSTalk script to drive Acorn. First the script reads in the promo codes from the file that iTunes Connect creates for you when you generate promo codes. Then for each of the codes, the script opens our layout image, creates a new text layer with the promo code and styles it properly. Finally, it saves the newly created image with a proper name.

Here is what the script looks like :

var acorn = JSTalk.application("Acorn");

var codes = [NSString stringWithContentsOfFile:
                @"/Users/twenty3/Desktop/SnoGlobePromoCodes.txt"];
var lines = [codes componentsSeparatedByCharactersInSet:
                [NSCharacterSet newlineCharacterSet]];

var sourceFilePath = "/Users/twenty3/Desktop/"
var sourceFileName = "SnoGlobeMooCardsBack";
var sourceFileExtension = ".png";
var destinationFolder = "SnoGlobeMooBacks/";

for (i=0; i<[lines length]; i++)
{
    var doc = acorn.open(sourceFilePath+sourceFileName+sourceFileExtension);

    var layer = doc.layers()[0];
    var wc = doc.windowController();

    var shapeLayer = [wc addNewShapeLayer:nil];

    var textArea = [shapeLayer addTextWithBounds:NSMakeRect(526, 106, 264, 40)];

    var promoCodeText   = [[NSMutableAttributedString alloc]
                            initWithString:[lines objectAtIndex:i]];
    var promoCodeFont   = [NSFont fontWithName:@"Menlo-Bold" size:30];
    var promoCodeColor  = [NSColor whiteColor];
    var promoStyle      = [[NSMutableParagraphStyle defaultParagraphStyle]
                            mutableCopyWithZone:NSDefaultMallocZone];

    promoStyle.setAlignment(NSCenterTextAlignment);

    var promoCodeAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                promoCodeFont, NSFontAttributeName,
                                promoCodeColor, NSForegroundColorAttributeName,
                                nil ];

    [promoCodeText setAttributes:promoCodeAttributes
                range:NSMakeRange(0,[promoCodeText length])];
   
    [textArea setContents: promoCodeText];
   
    doc.dataOfType("public.png").writeToFile(
            sourceFilePath + destinationFolder +
            sourceFileName + i + sourceFileExtension );
    doc.close();
}

[acorn activate];

Now, I got a little bi-polar there going back and forth between Objective-C style brackets and plain ol’ JavaScript style function calls. You can use whatever syntax makes the most sense to you personally though.

And here is a sample of one of the generated images:

PostageMooCardsBack0.png

Using this technique we generated all 300 images in something like 10 minutes. Add a little time to that to create the script and it added up to a whole lot of time saved. Plus, it was way more fun than the copy/paste dance it would have taken to do this by hand.

Count me in as a fan of JSTalk. Its such a cool technology and Gus has been kind enough to develop and distribute it completely free of charge! If you develop Mac apps you should think about dropping in support for JSTalk. If you have the need to do some automated image manipulation or creation, Acorn + JSTalk may be the perfect tool to tackle your problem.

2 Comments »

BusyCal Public Beta

July 27th, 2009 by Chris

Local Seattle software developer and friend of the sheep, BusyMac, have just released their latest creation into public beta. BusyCal is a fully integrated replacement for iCal.

We use iCal heavily around here and to be honest, it feels rather neglected these days. I’ve been using BusyCal for a little while now and I can report if you are looking for an iCal replacement you’ll not likely be disappointed. My two favorite features so far include publish and subscribe of calendars on the LAN and an event editing interface that is so much smoother than the changes brought to iCal with Leopard. I also love the live weather integration.

Head over to BusyMac’s site and sign up for the public beta and get some relief for your calendaring ailments.

Comments Off

UW Course on Mac and iPhone programming

July 15th, 2009 by Chris

The University of Washington is now offering a certificate course in Macintosh and iPhone programming.

This program is offered in 3 parts, with the first class that introduces objective-C and Cocoa starting this fall. Our good friend Hal Mueller is teaching the first course. The advisory board for this program is comprised of many of the best and well-known Mac and iPhone developers in the region, so you know the content is going to be great.

If you are in the Seattle area and looking to become a master of Cocoa and Objective-C, you don’t want to miss out on this opportunity. I know that the classes will fill up quick, so apply soon.

Comments Off

Spike Wants You…

April 22nd, 2008 by Chris

for the RogueSheep Army.

Things are really starting to cook around here lately. We have a variety of new clients discussing fresh projects and long-term partners coming back with some exciting plans for the remainder of this year. We are also fully engaged in work on our own technology platform that is centered around automated publishing. It has been a busy year and I think I can still see January back there not too far down the timeline.

Those of you that know me, know that I hate saying no. Having to turn down excellent opportunities and slowing down work on our internal projects one to many times has finally tipped the balance. We are ready to shepherd in a new engineer in the Seattle office in the very near future. The full details and job application form are available online.

Send us your résumé if you are interested or pass the word on to anyone you know that might be a good fit. I’m really looking forward to seeing a few fresh muzzles around here.

Comments Off

Ask Apple to Support Virtualization on the Desktop

March 22nd, 2008 by Chris

Craig Hockenberry, developer of fine applications such as Twitterrific and other goodies over at the Icon Factory has called on developers to join his crusade to convince Apple to support virtualization on the desktop.

Currently, Apple’s licensing restrictions for the Mac OS prevent the desktop client from being used as the guest operating system in a virtual machine. Because of this limitation virtualization tools such as VMWare Fusion or Parallels Desktop prevent you from installing the MacOS into a virtual machine.

This limitation in purely for licensing compliance. With the release of Leopard, Apple has modified the software license so that virtualization is allowed for OS X Server. Both VMWare and Parallels have betas that allow installation of Leopard Server in a virtual machine. This relaxation of the restriction for servers is a step in the right direction. We may even put that to use on our intranet here at RogueSheep.

Still, I believe that nearly all developers can benefit from virtualization of the standard MacOS. Craig makes excellent points about testing in various versions of the OS and easily having parallel installs of your development environments such as Xcode. In our work, we run into even more situations on a regular basis that I wish we could use virtualization for.

We often have multiple projects in progress for several different clients or our own in house development. Frequently, work for a particular client will require all manner of supporting frameworks and libraries as well as specific configuration of InDesign, InCopy and the various Creative Suite applications to enable the proper operation of a workflow environment.

Many times as one project is winding down, a new project is beginning. Sometimes the components required for two projects that any one of us happen to be working on at one time will conflict. Other times the pain comes from just having to juggle the configuration of the development environment and supported applications when switching contexts between projects.

If we could virtualize the MacOS, each project could start with an image that was prepared with our needed development environments and configured properly for the system that is being developed. Only one person would have to do this configuration and the result could be shared with all members of our team. When any one of us was forced to switch projects for a quick bug fix or consultation, it would be as simple as launching the appropriate virtual machine. The benefits to our work and our clients, Apple’s customers, I think is clear!

I’m not going to claim I know the exact reasons for Apple’s restrictive licensing. I will suggest though that I would be absolutely fine with requiring Select or Premier membership in the developer program to gain this support. If Apple wants to work with VMWare so that the only desktop OS that will install virtually are those downloaded as assets from our ADC benefits, I’m game.

I chatted briefly with the VMWare folks at MacWorld this year. They said they would love to add support for virtualization of the standard Mac OS. They encouraged all of us that need virtualization to contact Apple and let them know about our needs. Personally, I’ve done just that.

If you are developer using a Mac, I urge you to read Craig’s blog posting and then file your own bug, referencing the bug he notes.

Comments Off

Coda Developer Screencasts

January 27th, 2008 by Chris

My favorite application for creating web layout and sites has quickly become Panic’s excellent web-editing swiss army knife, Coda. Before Coda I used to really dread any website duties that fell on my shoulders. Now I sail through those tasks with ease and even, dare I say, enjoyment.

Steven Frank, Panic co-founder and Mac programming sage, has recently posted several screencasts for web developers seeking an introduction to Coda. If you haven’t tried Coda yet, these short tutorials will surely excite you into downloading the trial. If you are already tinkering around in the application, you will probably find a few goodies you may not have discovered yet in your personal explorations.

Leave A Comment »

Iron Coder VII

October 31st, 2007 by Chris

Attention Macintosh Programmers : Iron Coder 7 has been scheduled. Clear your weekend and put on your creative-codin’ hat. I think 7 may be my new lucky number…

Update : IC VII is going to be 9 days long and the Grand Prize is now an 8GB iPod Touch! Thanks to our Seattle brethren at Brain Murmurs for providing this enticing booty. Look for the API and theme at 7PM CST on 11.09.2007.

Leave A Comment »

Acorn : innovative Mac OS X image editing

October 28th, 2007 by Chris

I’m late to the party as usual, but I’d be remiss if I didn’t urge any of you reading that don’t already know to check out Flying Meat’s new image editor : Acorn. Acorn is a light-weight bitmap image editor with a focus on ease of use. Gus took a moment to rethink the typical Photoshop interface cloning technique that most alternative editors use as a launching point and has given us something innovative and refreshing.

Rather than pummel you with a plethora of separate floating palettes, Acorn concentrates the tools you need to get your most common tasks done in a single, straightforward palette. Under the hood, Acorn leverages Core Image and the rest of Apple’s excellent graphics frameworks to bring you excellent performance and a good dose of power.My personal favorite Acorn feature : the filter panel. Flying Meat licensed RogueSheep’s Core Image filtering library found in our Magma Effects InDesign plug-in for Acorn. Applying image effects in Acorn uses the very same core component found in Magma Effects! There’s a little sheep in that nut. I’ll let you in on a secret: there is also a sheepy easter egg in Acorn as well. Good hunting!

Gus tells me Acorn has been doing quite well. The reviews across the web are very favorable. Acorn also enjoyed being in the top 10 of Apple’s most popular downloads for a good run over at the Downloads site. If you haven’t downloaded it yet, be sure to check it out.

I’m looking forward to seeing what Gus builds on top of this excellent premiere release.

Leave A Comment »