if ((rgb[0] + rgb[1] + rgb[2]) / 3 < 128) { colorname.style.color = 'white'; } else { colorname.style.color = 'black'; }The only thing that is a bit interesting here. The use-case? You need a color quickly and click until you find a nice one. You can download the program under package. Unzip and open index.html.
Saturday, February 28, 2009
JavaScript: My hello world
Today I want to add more content to this blog that relates to the
programming languages that are written down on my CV. Many
programmers write down everything they had contact with, and claim
expertise. So I want to build up some petite portfolio, which is fun
to do anyways.
I want to start with a small application written in JavaScript (from
now on I will refer to it with JS). The
application should show a square and a little button should be at the
ground. After pushing the button the color will change randomly.
The development actually took me just half an hour. And every file
was validated. The first time I used JSLint. Which shows some real
shortcomings in JS. Why are there global objects? No import
Math or a declaration of a module. And functions have to be defined
with a var statement. This is pretty ugly.
Hm, the program is not so interesting after all. But better, than a
simple hello world. For the font I have used Georgia, because the
numbers align so nicely. The font changes after the algorithm
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment