Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and

Wednesday, 5 November 2008

Size Matters

The language api strongly recommends the use of magic numbers (rather than variables) for the dimension of the display window. Which is a pity because size matters, what looks good on a mobile phone is going to look stupid on your 52" plasma tv. It is also a pity since I had quite fancied setting the dimensions to produce a display window where width and height are in the golden ratio.
Since there is example in the api where the dimension is set as proportion of the screen size (doesn't work for applets though, where you would need to trust the browser to tell you its window size), I decided to 'just do it'.

A rectangle with aesthetically pleasing proportions will have sides
such that (width+height) / width = width / height
This equation has the solution such that
φ = (1+√5) /2 ≈ 1.618... where φ is an irrational number.
So I would propose to set height to a value say 400, then
width = floor(400 * φ), the floor being required since size requires int for pixel size.

I know this works because I've already coded it, but before I get my hands on the "Book", I'm reluctant to expose the code.

No comments:

Post a Comment


Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby- and processing-3.2.2