Sprouting Acorn

Not long after my previous post, I found raytraced renderings of Life, which included some code, and these images, which lacked documentation but are undoubtedly raytraced.

My previous post used MATLAB’s built-in 3D rendering functions, and it wasn’t pretty. It also got really slow and harder to look at as the forms got bigger. I’m doing some 3D segmentation of the forms (for science), and I need to visually check those results. MATLAB’s not up to handling so many polygons. I needed an external renderer.

So I built a MATLAB to YafaRay pipeline and started rendering the famous (and huge) Acorn form through 57 generations. In this light it looks like something out of Minecraft.


Technical Approach, MATLAB-side

Most 3D object specifications, including Yafaray’s internal xml scene description, accept a list of 3D points, and faces that reference those points. My approach is to construct the scene one layer at a time from the beginning of the simulation to the end.

For each live cell, define the four points in its base, and make the bottom face. Define the four points for its top, and make the top and side faces.

This simple approach on ...

Explorations in Conway's Life

Conway’s Game of Life is a set of rules for a a cellular automata, an infinite lattice of cells that are either alive or dead at any step in time. A few simple rules form the basis for an entire universe of possibilities.

From Wikipedia:

  1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.

  2. Any live cell with two or three live neighbours lives on to the next generation.

  3. Any live cell with more than three live neighbours dies, as if by overcrowding.

  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

I came back to it to explore its potential as a virtual world for virtual agents to develop knowledge representations. I made a simple implementation in MATLAB to calculate a single time step:

function grid = life(grid)
% LIFE outputs the next step to a game of life
% Outputs the next step of conway’s life

% Number of neighbors:
neighbors = conv2(grid,[1 1 1; 1 0 1; 1 1 1],'same’);

% Any live cell with fewer than two live neighbors dies, as if caused by under-population.
grid(neighbors<2) = 0;
% Any live cell with ...

iPhone Color Picker gets a little love

Back in August I put out an open source color picker for the iPhone. Announced here. It hasn’t recieved much attention in the way of people writing about it, but it has been downloaded over 600 times!

A couple of weeks ago I gave the project a little more love. The UI’s been polished, some internal code cleaned up, documentation improved, and wiki populated. Next on the docket is a truly polished version for iPad modal views.

One day soon I’ll push out an updated version of TrustyBook with the improved color-picker code.

iphone color picker screenshot

iPhone Color Picker


This code now lives as iOS Color Picker on GitHub and is vastly improved. There is an example project showing how to use the color picker, also on GitHub.

Between two conferences, ASIC in Bend and CogSci in Portland, I’ve taken a brief detour into Seattle. In addition to walking around the city and putting the finishing touches on my talk for CogSci (here’s the corresponding paper) I took it upon myself to make a super-simple iPhone app in the shortest amount of time possible. Without a lot of starting experience in iPhone development, it turns out that it took me about two days of mostly not working on it. But this post isn’t about that app; I’ll write about that in the near future when the app’s submitted to the appstore and I have some time to craft some “Marketspeak”. This post is about my adventures in crafting a color-picker for the iPhone.

Apple wasn’t kind enough to include a system color-picker in iOS. And given the iPhone’s general bend against productivity that’s only fitting. Googling for iPhone color-picker code returns a bunch of options that amount to a few ...

Introducing <em>py</em>&#8202;phenate

One More Piece of Typography for the Web

Not long ago a friend mentioned that he wanted to start an online magazine. I was instantly captivated by the idea, and I set out to build a simple infrastructure for a generic magazine. I also wanted to help preserve the idea that this was going to be a magazine that happened to be online, not a collection of blogs, stories, articles, etc. To me this meant presenting the layout and type as though it were a true print magazine.

Now, I am not an expert in typography. Not by any means. But I have been using LaTeX to prepare documents for a while, and have come to appreciate well-set text. A major roadblock in bringing well-set type to the web in an inability to control line length. Making text full-justified leaves unsightly gaps, and left justified text, while significantly more legible, doesn’t carry the elegance that is more easily achievable in print media. Setting aside the inherent spatial flexibility of the web as medium, a major issue preventing us from making text look as good as it can is the lack of automatic hyphenation of words across lines.

It turns ...

Detecting Displays

In the process of making Mirror Displays I learned more or less what Quartz Display Services in Mac OS X has to offer. It more or less lets to get and set all size, position, color, gamma, mirroring settings for attached monitors. It lets you fade the monitors in and out, and lets your app monopolize output to any monitors. An important element to the Display Services though, is that you can register to be notified of any changes to the displays.

I’m writing this particular post because I know that Java has some problems when it comes to dynamically detecting multiple monitors when you go and connect and disconnect them. Though I certainly hope Sun eventually fixes the problem, this sounded like the sort of thing that unfortunately needs to be solved on the native platform. I haven’t done any programming in Windows or Linux in a long time, but I hope I can help those using Mac OS X by showing you a barebones program that just sits and listens for display changes. I’m not going to make it talk to Java, but you make a little client-server setup, or maybe you could use the ...

Django is Fantastic!

In just a couple of hours, I’ve really pushed rather far forward with this blog project. I decided to look at what Django can do. Django is a framework for building web applications that GAE features pretty prominently. So far I’ve used it to populate the pages of this blog with text from the blog entries. But today I discovered two interesting elements to Django that I hadn’t suspected were there: template inheritance, and HTML sanitation. Both are touched on here in their documentation. With template inheritance, I can make one general template for the bulk of the site, and have sub-templates encapsulate the differences between pages. The base template I’m using does all the work of importing the CSS, building the footer, and so on. The sub-templates actually take care of the content. So now the files for individual pages are really cut down to their logical content:

{% extends "base.html" %}

{% block navbar %}
  <a class="selected">Blog</a>
  <a href="/Projects/" class="unselected">Projects</a>
{% endblock %}

{% block content %}
  {% for entry in entries %}
    <div class="blog-entry">
      <h1 class="blog-entry-title">
        {{ entry.title }}
      <div class="blog-entry-date">
        {{ entry.date|date:"F d, Y" }}
      <div class="blog-entry-body">
        {{ entry ...

Incremental Progress

Today I took a few minutes to clean up some of the CSS like I’ve been wanting to. They’re not done, but the design is a bit cleaner, and I’ve gotten rid of a bunch of tags I’m never going to use. I also implemented a rudimentary administrative system for the blog. It forced me to start logically dividing some of the code into strict administrative versus blog functions. For example, the core code for the blog1:

from google.appengine.ext import db
from google.appengine.ext import webapp

from google.appengine.ext.webapp import template

import os

class Post(db.Model):
  author = db.UserProperty()
  title = db.StringProperty(required=True)
  body = db.TextProperty(required=True)
  slug = db.StringProperty(required=True)
  date = db.DateTimeProperty(auto_now_add=True)

class Comment(db.Model):
  slug = db.ReferenceProperty(Post,required=True)
  author = db.UserProperty()
  authorName = db.StringProperty()
  authorEmail = db.EmailProperty()
  authorHomepage = db.LinkProperty()
  body = db.TextProperty(required=True)
  date = db.DateTimeProperty(auto_now_add=True)
  rating = db.IntegerProperty()

class BlogEntry(webapp.RequestHandler):
  def get(self, slug):
    post = Post.gql("WHERE slug = :1",slug)
    if post.count() == 1:
      post = post[0]
      template_values = {
        'entry': post,
      path = os.path.join(os.path.dirname(__file__), 'entry.html ...