Saturday, September 12, 2009

Logo II.


This is my next try:
However, I'm not satisfied with that... I simply wanted to be it a little bit less linear, but now it looks falling apart. The double border around seems departed now.

Being short of time, I'll only upload the differences in the code.

Now I'm using this line, to determine the difference horizontally:
int diffWidth = Math.min(i, width - i - 1)/2;
This implies, that the gradient will be somewhat smaller horizontally than vertically. (Half of it..)
A small problem with this is, that it doubles width of the vertical borderlines. I'll fix that next week, it's not that cool now.

The other change was, the nonlinearity.

Instead of the modulo function, now I'm using a whole new function to determine, what heights will be grey:
if(isGrey(diffMin)) grey = true;
which is equal to:
grey = isGrey(diffMin);

And the function is:
public static boolean isGrey(int diff)
{
int counter = 6;
int sum = counter;
while(sum <= diff)
{
if(sum == diff)return true;
counter+=4;
sum += counter;
}
return false;
}

Well, the small problem with this is, that it computes every possible height every time. It's not a big deal, since it runs in a few milliseconds, but it would be faster, if I first create a HashSet of integer values, put in the first few values (in this case: 6, 13, 21, 30, 40, 51, 62, ...), and search in that HashSet every time. Maybe I'll do that later.
(However, that would be better even because I could set the heights of the lines manually, without writing an algorithm. For such a small application it would be maybe better.)

Okay, that's it for now, I'll come with a new logo next week.

No comments: