Placed in: Home arrow Programming arrow Webdesign arrow Generating the pixellogo from TechCrunch in HTML
Generating the pixellogo from TechCrunch in HTML

A while ago, the popular tech blog TechCrunch launched a new design for their website. Along with this design, they released a new logo. I wanted to generate this logo in HTML using jQuery.

HTML TechCrunch Pixellogo

This logo looked like the perfect candidate to do so, since it uses huge pixels and only a couple of colours (4 shades of green). With only little HTML, CSS and jQuery, I was able to generate this logo with not much effort.

Demo HTML TechCrunch Pixellogo   Download HTML TechCrunch Pixellogo

Did you check out the demo to see what we're going to do? This is how you can generate this pixellogo yourself!

HTML

As always, the HTML is kept really clean. For this demo, we only need one container that will hold all the "pixels" from the logo.

 
<div id="techcrunch">
    <!-- jQuery will inject the HTML here -->
</div>

Take note of the id which is used, since we refer to that in the CSS and the jQuery.

CSS

On to something more interesting, the CSS. As you can see, each pixel has a fixed width and height which will fill the pixellogo.

 
#techcrunch {
    width:240px; height:120px; margin:0 auto; }
.pixel { width:10px; height:10px; float:left; }
.shade1 { background-color:#24e100; }
.shade2 { background-color:#1cbe01; }
.shade3 { background-color:#159700; }
.shade4 { background-color:#0a6300; }

The different shades are numbered. This is essential for the technique we use with the jQuery. The .shade1 is the lightest shade of green, the .shade4 the darkest.

jQuery

Now to generate the pixellogo! The code isn't that hard to understand (I added some comments as well), so just look at it first.

 
// Two dimensional array that represents the logo
// Each number represents a different shade, which is referred to in the CSS
var techcrunchLogo =
[
    [1,1,1,1,1,1,1,2,1,2,2,2,0,0,0,0,3,3,4,4,4,4,4,3],
    [1,1,1,1,1,1,1,2,2,2,2,2,0,0,0,0,3,4,4,3,4,4,3,3],
    [1,1,1,1,1,1,2,1,1,2,2,3,0,0,0,0,4,4,4,4,3,2,2,3],
    [1,1,2,2,1,2,1,2,2,2,1,1,0,0,0,0,3,4,4,3,2,2,3,2],
    [0,0,0,0,2,2,2,2,0,0,0,0,2,2,2,3,0,0,0,0,0,0,0,0],
    [0,0,0,0,1,1,2,3,0,0,0,0,2,3,3,3,0,0,0,0,0,0,0,0],
    [0,0,0,0,1,2,3,3,0,0,0,0,2,3,3,4,0,0,0,0,0,0,0,0],
    [0,0,0,0,2,2,2,2,0,0,0,0,4,3,4,4,0,0,0,0,0,0,0,0],
    [0,0,0,0,2,3,2,2,0,0,0,0,3,4,4,4,4,3,4,3,3,2,3,3],
    [0,0,0,0,2,2,2,3,0,0,0,0,4,4,4,3,4,3,3,3,3,3,2,2],
    [0,0,0,0,2,3,3,3,0,0,0,0,4,4,4,4,3,3,2,3,3,2,2,2],
    [0,0,0,0,3,2,3,3,0,0,0,0,4,4,3,4,4,3,3,2,2,2,2,2]
];
 
// Generate the logo by iterating over the techcrunchLogo arrays
for(var i = 0; i < techcrunchLogo.length; i++) { // Rows
    for (var j = 0; j < techcrunchLogo[i].length; j++) { // Columns
        $("<div />")
            .addClass("pixel")
            .addClass("shade" + techcrunchLogo[i][j])
            .appendTo($("#techcrunch"));
    }
}

As you might have seen, the most important part is the techcrunchLogo variable. Each number represents a different shade, which is referred to in the CSS. We than iterate over the arrays to "paint the pixels" from the logo, and add them to the container.

That's all there is to it! We now generated the TechCrunch logo in HTML using some nifty jQuery and CSS.

Conclusion & Download

I hope you understand this was just a little fun project; In theory, you could even make the CSS .pixel class have a width and height of 1px and generate anything you like. Still, this looked like the perfect example for me since the pixels were big and not a lot of colours are used.

Demo HTML TechCrunch Pixellogo   Download HTML TechCrunch Pixellogo

What do you think of this technique? Would you like to improve the code? Would you rather see something different? Feel free to share!


Tags:  pixellogo generate techcrunch html jquery

Interested in this topic? You might enjoy another article I've written called

Did you like this article? Subscribe to my feed or email to keep updated on new articles.

Spread the word and submit to:
Digg!Reddit!Del.icio.us!Facebook!StumbleUpon!
Comments
Add NewSearchRSS
jQueryRoxx   2011-07-24 02:24:38
Gravatar image
Code:
(function ($, $pixels) {

    $pixels = $();
    $.each("111111121222000033444443111111122222000034434433111111211223000044443223112212122211000034432232000022220000222300000000000011230000233300000000000012330000233400000000000022220000434400000000000023220000344443433233000022230000444343333322000023330000444433233222000032330000443443322222", function (index, value) {

        $pixels = $pixels.add($("", { class: "pixel shade" + value }))

    });

    $("#techcrunch" ).append($pixels)

}(jQuery))


(Sorry for the previous comment, please delete it)
Marco - Very cool!   2011-07-24 02:36:51
Gravatar image That's a very impressive way to approach this problem jQueryRoxx, well done! It's way shorter (which means less KB in size), and probably faster as well. Thanks a lot for sharing!
jQueryRoxx   2011-07-24 12:46:06
Gravatar image Yep, but your comment system stripped out the required "<div/>" line 4 :)
Himanshu   2011-07-25 17:38:53
Gravatar image i really liked the new TC logo. now i know how its made. great share.
zach - web techie   2011-08-02 22:37:12
Gravatar image This pretty much sums up what needs to be seen around some parts of the web today, and even I could benefit from some of it http://www.creativeautomaton.com.
moviman   2011-08-09 16:36:34
Gravatar image As a webmaster, I am really into this logo generator sites, I use these logo generator in my own movie review siteshttp://www.cinecraze.net/movie/comedy as well. Thank you for sharing this precious info.
Eric Lenhard   2011-09-07 09:56:00
Gravatar image Great one! Will definitely use something from this tutorial in my projects. Thanks!
Aida - Amazing   2011-09-11 04:14:39
Gravatar image thanks very nice and useful
here can you check my site tips tricks and backlinks cheers

BACKLINKS-Click HERE
joanla - Great one!   2011-10-18 15:00:42
Gravatar image All questions on your blog can be found in the answer,thanks very much!
joanla - re: Great one!   2011-10-18 15:02:04
Gravatar image :lol: All questions on your blog can be found in the answer,thanks very much!
Christian Louboutin   2012-04-06 08:20:56
Gravatar image What is the talking cricket xiao Chen or know, elementary school textbooks painting of a figure; How to sing, he'd do not clear.http://www.louboutinshoesuksale.co.uk/
Think360studio   2012-04-30 11:02:06
Gravatar image Hi. Awesome work you had done. next time I"ll definitely use it. Thanks for sharing this article.
louboutin   2012-05-12 09:27:23
Gravatar image and let both young and old will, for their tangled China a slow 2 see three through? And in China, so RongSheng can so gone young man, with young of China in modern times and slowly old?
takeyourjerseys - take your jerseys   2012-05-25 14:08:37
Gravatar image New Jersey Devils were established in 1982. Their head coach is Jacques Lemaire and their captain is in vacant. The arena is Prudential Center in Newark. New Jersey Devils Jersey are owned by Jeffrey Vanderbeek, who bought them in 2004 for $125 mil and now they are worthy $218 mil. The colors of the New Jersey Devils Jersey are red, black and white. We provide the top quality NHL Jersey in lower price. Show your support to New Jersey Devils Jersey with this gorgeous jersey."
NHL New Jersey Devils #15 Jamie Langenbrunner CCM Red and Green n
mbt - mbt shoes   2013-03-19 02:52:42
Gravatar image exhibition form and poetic expression only by eyes. Get the invitations can see shows clear in detail in the invitation
Read more...
Name:
Email:
  Gravatar enabled.
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Security Image
Please input the anti-spam code that you can read in the image.
Unsubscribe from e-mail notifications.
 
< Prev   Next >
Subscribe

Subscribe to Marcofolio