Things that are changing!

October 14, 2010 Leave a comment

It’s been a bit since I last posted… a lot has been going on. I’ve had a new baby (girl #2, yay!), recorded a ton of videos for 3D Buzz in our Software Engineering course, started working on a new light-weight blog engine (which I may retire and just stick with something that’s already out there… not sure), and a few other projects that I’ll keep unmentioned for now.

So yeah, lots going on.

In the next month or so I’ll be transitioning over to a new host as doesn’t meet my up-coming needs. Look for it soon! πŸ™‚

Categories: Personal


September 15, 2010 Leave a comment

I’ve been working on familiarizing myself with various JavaScript frameworks and methodologies over the past few weeks at work. I recently came across the Cappuccino framework. While I had seen this in the past, I never really tried it out. Well, last week I actually started poking around with it. πŸ™‚

The basic idea of the framework is to provide a platform for building web-based applications. That means it’s a library nothing like jQuery where you pick and choose what elements of jQuery you want, Cappuccinno is an all-or-nothing solution.

The thing I found most interesting was that the JavaScript you write is actually written in a language they call Objective-J. At its heart, it is Objective-C for JavaScript. This is pretty compelling as in theory you could more easily port an exisiting Cocoa application for the web. In practice, this is a long ways out as there is a lot of the underlying framework missing.

I did find writing the Objective-J code very familiar as I’ve used Objective-C in the past. Is this the new way to write web apps? I don’t know… definitely needs some work to before it truly becomes a v1 product, but it has potential.

Some might cringe that it abstracts the “HTML-ness” away from the web, but I don’t necessarily think that is a bad thing.

The most interesting thing about Cappuccinno, to me at least, is there Atlas project. It’s basically Interface Builder for JavaScript, which I find very interesting. They also have tools to convert your Nib files to Cib (basically a Cappuccino Nib file) files which allow you to load up UI that way.

It’s definitely a framework you should look into if you are developing a new web-app from scratch. It obviously doesn’t have the widespread use like jQuery does, but that’s not always a bad thing.

Categories: JavaScript, Programming

HTML5 Canvas and Dashed Lines

September 7, 2010 20 comments

I’ve been spending a lot of time with HTML5’s new Canvas tag, and I have to say, I’m quite excited with it. The gratification you can get with a small set of code rendering some images is great! It’s nothing like what you need to get going in C++ and OpenGL or even XNA – pure, simple, and of course, very limited.

Canvas is currently so limited that you cannot even draw a simple dashed line! Straight lines, no problem.

This is clearly a problem that needs fixing and luckily enough, I have just a solution. πŸ™‚

So, how might we go about adding this functionality. Quite simply! Thanks to the ability for JavaScript’s prototypical nature, and maybe more accurately, it’s dynamic nature, we can extend the functionality of the Canvas object so that we can make our new functionality look like it’s built-in.

Ok, so how do we get started? First we need to define our protype code. I’ve created a new JavaScript file called canvas.js to where we’ll put our code.

CanvasRenderingContext2D.prototype.dashedLineTo = function (from, to, pattern) {}

That adds the ‘dashedLineTo’ function to our canvas protype.

Next we need to actually implement the function. I’m not going to actually go through and explain it all, but the idea of the code is to use the pattern parameter to define the length of each dash and each space, in alternating order, for your dashed line.

CanvasRenderingContext2D.prototype.dashedLineTo = function (fromX, fromY, toX, toY, pattern) {
  // Our growth rate for our line can be one of the following:
  //   (+,+), (+,-), (-,+), (-,-)
  // Because of this, our algorithm needs to understand if the x-coord and
  // y-coord should be getting smaller or larger and properly cap the values
  // based on (x,y).
  var lt = function (a, b) { return a <= b; };
  var gt = function (a, b) { return a >= b; };
  var capmin = function (a, b) { return Math.min(a, b); };
  var capmax = function (a, b) { return Math.max(a, b); };

  var checkX = { thereYet: gt, cap: capmin };
  var checkY = { thereYet: gt, cap: capmin };

  if (fromY - toY > 0) {
    checkY.thereYet = lt;
    checkY.cap = capmax;
  if (fromX - toX > 0) {
    checkX.thereYet = lt;
    checkX.cap = capmax;

  this.moveTo(fromX, fromY);
  var offsetX = fromX;
  var offsetY = fromY;
  var idx = 0, dash = true;
  while (!(checkX.thereYet(offsetX, toX) && checkY.thereYet(offsetY, toY))) {
    var ang = Math.atan2(toY - fromY, toX - fromX);
    var len = pattern[idx];

    offsetX = checkX.cap(toX, offsetX + (Math.cos(ang) * len));
    offsetY = checkY.cap(toY, offsetY + (Math.sin(ang) * len));

    if (dash) this.lineTo(offsetX, offsetY);
    else this.moveTo(offsetX, offsetY);

    idx = (idx + 1) % pattern.length;
    dash = !dash;

To use this code, just include your new canvas.js script file in your .html file in a script tag, and voila!

  <script type="text/javascript" src="canvas.js"><script>

If you know of a better way to do this, be sure to let me know!

Update: So, maybe I should have tested that version. πŸ™‚ Updated the code to actually work and not rely on some other pieces of a library I’m working on.

Categories: HTML5, JavaScript, Programming

I’m Back!

September 6, 2010 5 comments

I’ve typically used my blog either as a sounding board for things I’d like to see changed in a product I used to work on (nothing says fix-it like a post showing how to do something someone says cannot be done) or just random postings.

Well… I’d like that to change. I’ve got a lot of cruft up in this old brain of mine and it’s time to post some of that in hopes that others may find it useful, or maybe just amusing at the very least.

I’ve got a new job, still at the same company, just with a different group. So far it’s been great, APP BUILDING APP BUILDING APP BUILDING! πŸ™‚ Of course, the fun will end shortly as we get back to some serious work. One of the best things about this job is that I’ve gotten back into, or shall I say more accurately, actually getting into JavaScript.

I’ve forgotten how fun dynamic languages are. Having spent most of my time in C# or C++ in the past few years, it’s freeing to be able to spend a significant amount of time in a language where I don’t have to come up with a class, where if I need a function to do something I can just create it inline and pass it around like a normal variable, or where parsing a string doesn’t take 10 lines of code… yeah, I’m looking at C++!

Anyway, the point is that I’ll be blocking off some time every week to two to write up a blog about something helpful that I learned, most likely pertaining to some problem I’ve faced, in hopes that some other poor sap won’t have to go through the same ordeal I have but can use my solution and move on to solving his/her real problem at hand.

See you soon!

Categories: Personal

.NET Framework 4 Beta 2 Install Errors?

October 19, 2009 Leave a comment

If you’re like me and you run both Windows and OS X, you might find yourself in a odd predicament if you try to install Visual Studio 2010 Beta 2 – it may not install!!!

It turns out there is a fairly ridiculous bug in the .NET Framework 4 Beta 2 setup. The basics is that it tries to find a drive to extract out the setup file (why the current drive isn’t good enough is beyond me) and extract out the files there… well, on my setup with Bootcamp that gives me a 160GB partition with OS X and an 80GB partition for Windows. Well, the setup finds the E drive (I have Snow Leopard so I can read HFS drives in Windows) which is my OS X drive and the drive with the most free disk space. Next it tries to extract itself out to it but fails as the HFS partition is read-only.

The workaround is fairly easy to do and the bug should be fixed by the time RTM comes. To fix it, simply remove the drive letter mapping from your OS X drive in Windows, install the .NET Framework 4 Beta 2, and then add the drive letter back to your OS X partition.

After that, all should be happy. πŸ™‚

Categories: Programming

Hi Google

September 16, 2009 Leave a comment

What, it took like a day for me to switch back? 😦 I still despise the large font for the search but I’ve found that Bing just doesn’t do a good enough job for my programming related searches. I figured I’d let everyone know that I’ve thrown in the towel for now and have gone back to my good ‘ol google.

Categories: Personal

Bye Bye Google

September 15, 2009 2 comments

Well, it’s time for me to move on from Google. With their recent changes to the “UI” or should I rather say the humungous buttons and text, I’m off to Bing land. Bing’s results have been getting better and better, so there’s really not much reason for me to stay with Google. I’ve also been able to update my search engine in Safari 4 thanks to Glims (if you’re on Snow Leopard you want to get build 21 – currently in RC – or later). Also, I’m looking forward to some of the cool Bing 2.0 features.

So there we have it… we’ll see how long it lasts. πŸ™‚

Categories: Personal