Phillip Trelford's Array

POKE 36879,255

Modern Art

A few backs I visited New York City taking in some of the many sites like the Empire State Building for the views, Grand Central Terminal for the oysters, Central Park for waffles & dinges, Harry’s Bar for steaks, the American Museum of Natural History for stars and stuffed animals and the MoMA for modern art.

MoMA

The department of Architecture and Design at the MoMA had 14 video games on display including PacMan. Are video games art? They sure are.

I also found an interesting piece by Philippe Decrauzat entitled D.T.A.B.T.W.H.A.H.E.

DTABTWHAHE

Here’s a short F# snippet to generate similar text blocks:

// Generate text from Philippe Decrauzat's D.T.A.B.T.W.H.A.H.E. 2010
let print (s:string) =
    [|
    for y in 0..s.Length-1 ->
        [|for x in 0..y-1 -> s.[x]
            for x in y..s.Length-1 -> s.[y]
        |]
        |> fun cs -> 
            System.String(cs) + 
            System.String(cs |> Array.rev |> Seq.skip 1 |> Seq.toArray) 
    |] 
    |> fun ys -> [|yield! ys; yield! (Array.rev ys |> Seq.skip 1)|] 
    |> String.concat "\r\n"
print "A HAPPY ENDING"

F# for Trading

While I was in New York I also gave a talk on F# for Trading at the local F# User Group:

Thanks for all the kind feedback.

Tate Modern

I work round from the corner from the Tate Modern in London. Last week I popped in and on my exit through the gift shop I picked up a book with the title Null Object and a postcard of a painting called Hyena Stomp by Frank Stella:

hyena stomp

I liked it as it reminded me of the end of level sequence in Robotron 2084 & Llamatron:


 

As an aside, I've been having a lot of fun recently making bleeps and beeps, more often found in 80s video games, with Korg's Monotribe analogue synth.

Inspired by Llamtron I’ve created a simple animated version of Hyena Stomp in Silverlight:


Music

Why not sit back and relax with some art inspired music:

Fractal Zoom in Colour

A few years back I put together a simple Fractal Zoom in Silverlight using gray scales.

Time for a little makeover with color:


Hold down the mouse button over the Mandelbrot and move the mouse to highlight a rectangle, then release the mouse button to zoom in on that area.

Implementation

To get a nice colour progression I used the HSB color circle:

let H,S,L = 0.95 + (10.0 * n), 0.6, 0.5

Then created a colour lookup table using a list comprehension:

[|for i in 0..maxIteration ->
    let n = float i / float maxIteration
    let H,S,L = 0.95 + (10.0 * n), 0.6, 0.5
    let H = H - floor H
    let r,g,b = RGB.FromHSL(H,S,L)
    0xff000000 + (r <<< 16) + (g <<< 8) + b|]

For the HSL to RGB conversion I converted Colin Eberhardt’s accepted Stack Overflow answer from C# to F#:

C# F#
double v;
double r, g, b;
if (A > 1.0)
A = 1.0;

r = L;   // default to gray
g = L;
b = L;
v = 
   (L <= 0.5) 
   ? (L * (1.0 + S)) 
   : (L + S - L * S);
if (v > 0)
{
    double m;
    double sv;
    int sextant;
    double fract, vsf, mid1, mid2;

    m = L + L - v;
    sv = (v - m) / v;
    H *= 6.0;
    sextant = (int)H;
    fract = H - sextant;
    vsf = v * sv * fract;
    mid1 = m + vsf;
    mid2 = v - vsf;
    switch (sextant)
    {
       case 0:
        r = v;
        g = mid1;
        b = m;
        break;
       case 1:
        r = mid2;
        g = v;
        b = m;
        break;
       case 2:
        r = m;
        g = v;
        b = mid1;
        break;
       case 3:
        r = m;
        g = mid2;
        b = v;
        break;
       case 4:
        r = mid1;
        g = m;
        b = v;
        break;
       case 5:
        r = v;
        g = m;
        b = mid2;
        break;
    }
}
ColorRGB rgb = new ColorRGB();
rgb.R = Convert.ToByte(r * 255.0f);
rgb.G = Convert.ToByte(g * 255.0f);
rgb.B = Convert.ToByte(b * 255.0f);
rgb.A = Convert.ToByte(A * 255.0f);
return rgb;
let v = 
    if (L <= 0.5) 
    then (L * (1.0 + S)) 
    else (L + S - L * S)
if v > 0.0 then                
    let m = L + L - v;
    let sv = (v - m) / v;
    let H = H * 6.0;
    let sextant = int H
    let fract = H - float sextant
    let vsf = v * sv * fract;
    let mid1 = m + vsf;
    let mid2 = v - vsf;
    match sextant with
    | 0 -> v, mid1, m
    | 1 -> mid2, v, m
    | 2 -> m, v, mid1
    | 3 -> m, mid2, v
    | 4 -> mid1, m, v
    | 5 -> v, m, mid2
    | _ -> L, L, L
else L, L, L
|> fun (r,g,b) –> 
   byte(r*255.),
   byte(g*255.),
   byte(b*255.)

Voila, happy zooming :)

Blog 101

This is a meta post to coincide with posting over 100 articles over 4 years, going back over some the more popular along with some of my own personal favourites. I started blogging regularly back in 2007 on the Applied Games Group blog, here’s a selection from there: 

Then in 2008 I started this blog with the motivation of keeping a record of some of the things I’ve learned while improving my technical writing skills with a view to working on a book. This week in collaboration with Tomas Petricek I signed a book deal with Manning.

Many of the posts are written during my daily commute from Cambridgeshire down to London, which takes just over an hour. The ideas for posts come at different times, more often when I’m away from my computer taking a walk or a cycle or having a bath. Once an idea has solidified in my mind, I usually start by writing a working title, an opening sentence, a brief outline and then fill in the gaps.

Tools/Tech:

Most popular articles

More often than not it’s the articles I least expect to be popular that are. Typically early views come from Twitter, and then from link sites like Chris Alcock’s Morning Brew and Alvin Ashcraft’s Morning Dew. My biggest traffic spikes have come from CodeProject.

My picks

A selection of interesting technology and some minor rants.

Mini Games

My interest in programming started with video games, and I still enjoy writing mini games. I typically write them in Silverlight so that I can embed them in the blog.

Open Source Projects

Introductions to some of my open source projects on CodePlex.

Thanks!

Thanks for all the feedback, it really helps, don't be shy :)