The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Making of: The XMasHack 2005

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Christian Neukirchen

Posts: 188
Nickname: chris2
Registered: Mar, 2005

Christian Neukirchen is a student from Biberach, Germany playing and hacking with Ruby.
Making of: The XMasHack 2005 Posted: Dec 27, 2005 6:42 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Christian Neukirchen.
Original Post: Making of: The XMasHack 2005
Feed Title: chris blogs: Ruby stuff
Feed URL: http://chneukirchen.org/blog/category/ruby.atom
Feed Description: a weblog by christian neukirchen - Ruby stuff
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Christian Neukirchen
Latest Posts From chris blogs: Ruby stuff

Advertisement

Maybe you already saw my yearly christmas greeting on ruby-talk:172428 (last year’s to be found here), but today I’d like to explain how I did it. If you didn’t run it yet, do that now and be amazed. ;-)

First of all, I needed to implement the actual logic. I’d only like to outline it here and leave the rest for the reader. You may want to read the complete, unobfusciated source.

The real snowfall happens in snowdrop!, where a random vector of snow heights gets increased by one in a way the difference to the neighbour elements is never greater than one. This vector then gets rendered in to_s onto a marshalled array with the greeting message by differentiating the vector and thereby figuring out which chars to use. Above the skyline snow randomly gets painted.

All this happens until all the vector’s elements are filled up. The logic is not very difficult but I tried quite a few ways to make it work best. I’d like to thank Frixon on #ruby-de for the inspiration; he had to write the mountain algorithm in Ada (I didn’t look at the code, only at the output).

Of course, that was the easy part. ;-) Now, the thing had to be styled. Since this years hack was a lot bigger than last years (2221 byte), I couldn’t simply reuse last years fir tree. I first tried to add some thicker border to it, but then I thought it would be boring if I used the same image twice.

So I took the PostScript star of first advent, gimped it a bit (solid fill, rescaling to an appropriate size and ratio since terminal fonts aren’t 1:1), then saved it into a portable grey map and solarized it into ASCII chars using a self-written script. The rest of the image (border and snow) was made manually using Emacs’ picture-mode.

The final ASCII image, consisting of * and and some custom text was then filled with code, using a similar script like last year.

It was some hours of work, some hours of fun and I hope you enjoyed it!

NP: The Melvins—Revolve

Read: Making of: The XMasHack 2005

Topic: Try Ruby is Done, Makes HTML Now Previous Topic   Next Topic Topic: A Writeup on the Phoenix Ruby Group Meeting

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use