News for hackers. Stuff that matters.
Re:Using prime numbers to make better backgrounds by BrandonM on Thursday April 07, 2011 @11:26AM (#2419815)
This is the perfect Hacker News article. I learned something new and mathematically-interesting about the natural world, the author came up with a clever hack to enliven backgrounds, and we learn how to apply that to improve our own designs.
Re:Using prime numbers to make better backgrounds by satori99 on Thursday April 07, 2011 @04:40PM (#2421113)
Totally agree. There have been quite a few articles recently that fall into this category.

pquerna's recent post about OpenSSL memory in node (and elsewhere) is another that comes to mind. http://news.ycombinator.com/item?id=2411144

keep 'em coming I say!

Re:Using prime numbers to make better backgrounds by derefr on Friday April 08, 2011 @05:27AM (#2423067)
It's interesting that it's almost impossible to pin down a verbal guideline for what people should be submitting (besides "anything that gratifies one's intellectual curiosity") but pretty easy to point to a given article and say that, yes, this definitely is Hacker News.

It'd be pretty awesome if we could have an HN that's just this sort of stuff (with a strong tendency toward false-negatives vs. false-positives—i.e. no "maybe good", only "definitely good.") I wouldn't mind even if it only had two or three new posts per day—fewer, guaranteed posts means I could actually stand to add it to my RSS reader, vs. the current HN which is more of a firehose: good to stick a bottle in every once in a while, not good to stand in front of.

Thinking on that, here's one way it could be implemented on top of the current HN: if there was some sort of "way, way up"-vote button that (besides being an actual "I wish I had N upvotes to give this" upvote-N-times button) worked as a sort of moral negative to flagging, such that when it had been hit [some threshold] times for an article, the article would get linked into the "/awesome" sublist, that might be enough to make it happen—if we trust the userbase to not abuse it.

If everyone started to way-way-up-vote everything they currently just up-vote, perhaps one could stick a CAPTCHA (or three) on it to make it just annoying enough to disuade abuse (at the cost of further false negatives from people now too lazy to use it.)

Re:Using prime numbers to make better backgrounds by JonnieCache on Friday April 08, 2011 @07:31AM (#2423296)
You can filter the homepage for submissions with a minimum number of votes:

http://news.ycombinator.com/over?points=200

HN has loads of hidden features. I suggest judicious use of google's search operators to find them all.

Re:Using prime numbers to make better backgrounds by danohuiginn on Saturday April 09, 2011 @01:43PM (#2427612)
there's also http://news.ycombinator.com/best, for (iirc) the top articles in the past 7 days.

Somebody should really put together a guide to all these half-hidden features, either as a wiki or an individual effort.

Re:Using prime numbers to make better backgrounds by TimothyBurgess on Thursday April 07, 2011 @06:02PM (#2421396)
Upvoted solely for "keep 'em coming!"

This article was truly awesome. I'm kicking myself for having not thought of it before because it seems like such a simple concept! Makes me wonder what else out there I haven't thought of... ;)

Re:Using prime numbers to make better backgrounds by gbog on Saturday April 09, 2011 @01:08PM (#2427520)
I dare to disagree. While learning about Cicadas and prime numbers is ok, its application to "enliven backgrounds" seems very futile to me. Hacking means breaking the rules, crack the black box, find new game changing ways to do things that will prove useful for a lot of people. Hacking is not about finding slightly vain design tricks.

In summary, this article is far from what I would upvote. A good indicator of the relative weakness of it is the few interesting comment it triggered.

In fact, some month ago I would come to HN, and read the comments, and find a lot of savoury meat for my curiosity hunger, without even bothering to get check the original article that was only the starting point of high-level exchanges of views on the matter.

PS: Recent articles seem to focus on visual design (pixels and colors), which is very surprising on a website that is so obviously anti-design...

Re:Using prime numbers to make better backgrounds by nadam on Thursday April 07, 2011 @10:30AM (#2419576)
Cool, but these numbers don't have to be primes. They just have to be coprimes (like (8,9)).

The least common multiple of two coprimes 'a' and 'b' is a*b.

http://en.wikipedia.org/wiki/Coprime

Re:Using prime numbers to make better backgrounds by dmvaldman on Thursday April 07, 2011 @12:45PM (#2420147)
Not for the cicada example, but yes for the web aspect.

In the cicada example the point is that one predator would evolve to align its boom cycle so that it had a common divisor with the cycle of the cicada.

Since the predator's cycle is variable, it is evolutionarily optimal if the cicada only comes out every prime number of years.

Re:Using prime numbers to make better backgrounds by mryall on Thursday April 07, 2011 @06:11PM (#2421424)
Why can't the predators evolve to have the same cycle as the cicadas, with a prime number of years?
Re:Using prime numbers to make better backgrounds by redthrowaway on Thursday April 07, 2011 @06:20PM (#2421458)
They can, but by being so highly variable, the cicada boom cycle becomes a less important survival driver than other factors, such as predator cycles, weather, etc. In a closely-paired ecosystem, with relatively few variables, you do see remarkable coevolution between predators and prey. When the prey removes their boom cycle from the dominant evolutionary stressors on the predator, differential survival of the predator will be determined far more by the dominant factors.

It's important to note that, for the cicada, they are not a staple diet but rather an opportunistic one that occurs only once in a few generations. This means that the predator's cycle would have to skip generations in order to be effective. This is unlikely, given that that cycle would have no evolutionary advantage in the intermediary, and would thus be diluted by more pressing concerns.

Re:Using prime numbers to make better backgrounds by endtime on Friday April 08, 2011 @01:54PM (#2424905)
Coprimality is still the relevant property. But if one number can be adjusted, then the only way to guarantee coprimality is for the other number to be a prime.
Re:Using prime numbers to make better backgrounds by wging on Friday April 08, 2011 @03:18PM (#2425234)
Almost. Coprimality can never be guaranteed. If the numbers are p and q, with p prime and q being adjustable, just take q=p. Then they match up, showing that this barrier isn't enough.

The other relevant barrier we have is probably that a 6-year wasp has difficulty stretching its cycle by a factor of 3--much more difficult than a single year or two.

Re:Using prime numbers to make better backgrounds by dangoldin on Friday April 08, 2011 @12:32AM (#2422469)
It's interesting that the cicadas have the cycles they do. Why not also go 23, 29, etc? There's obviously a trade off between being more frequent but also encountering more predators - I'm just curious why they settled on the cycles that they did.
Re:Using prime numbers to make better backgrounds by parfe on Friday April 08, 2011 @11:48AM (#2424285)
They only mate once before dying. I assume waiting 29 years would increase the odds of a pre-mating death. Maybe even death from old age. How long can an insect live?
Re:Using prime numbers to make better backgrounds by baddox on Thursday April 07, 2011 @11:51AM (#2419919)
Indeed. If you already have one tile that's, say 50px wide, you can easily find coprime sizes:

http://www.wolframalpha.com/input/?i=coprime+to+50

Re:Using prime numbers to make better backgrounds by IDisposableHero on Thursday April 07, 2011 @11:15AM (#2419765)
This is very well explained, but not all that novel. Brian Eno used to generate long soundscapes like this, using loops of mutually prime lengths of time.

Edit: See also -

http://en.wikipedia.org/wiki/Ambient_1:_Music_for_Airports

http://en.wikipedia.org/wiki/Generative_music

Re:Using prime numbers to make better backgrounds by jws on Thursday April 07, 2011 @12:14PM (#2420013)
It also is the core of "method ringing", a kind of bell ringing from the 17th century and persisting today. Imagine some folks clanging away at 10 bells in a church tower for hours on end, never repeating, and never developing a melody. Each person is operating a single bell and repeating their pattern with a unique period.

http://en.wikipedia.org/wiki/Change_ringing

Re:Using prime numbers to make better backgrounds by mturmon on Thursday April 07, 2011 @09:07PM (#2421962)
Ringing the changes uses permutations. The described method uses relatively prime numbers.

Both produce music according to a simple algorithm, but the algorithms are different.

Re:Using prime numbers to make better backgrounds by IDisposableHero on Thursday April 07, 2011 @12:26PM (#2420076)
Hah, that trumps my example by 200 years. Well done.
Re:Using prime numbers to make better backgrounds by gjm11 on Thursday April 07, 2011 @02:10PM (#2420505)
Except for the small detail that it isn't true. In change ringing, what you do is to cycle through some subset of the permutations of N bells. So you might begin 123456 123465 124365 and so on. The whole thing is made up of blocks of N bells in each of which each bell is rung once. Therefore, all bells have (on average) the same period: one ring, on average, out of every N.

The bells are hung in such a way that they naturally want to swing with equal periods, so you don't have to disturb one too much to make it ring one place earlier or later in the cycle. (A bell is never moved by more than two places.)

I don't see any reason why a peal of bells couldn't be set up to produce the effect jws described, but it wouldn't be at all the same thing as change ringing.

Re:Using prime numbers to make better backgrounds by jws on Thursday April 07, 2011 @09:17PM (#2421978)
But each individual in method ringing is repeating their pattern. (at least as Wikipedia explains it.)
Re:Using prime numbers to make better backgrounds by nadam on Thursday April 07, 2011 @11:36AM (#2419856)
Yes it is a known technique also in 3D games. Related, but more complicated (research) topic is infinite/arbitrarily-sized non-looping texture generation from arbitrary sample images.

http://www.cs.sunysb.edu/~vordonezroma/texturesynth.pdf

(There are some mind blowing generated images in the linked PDF.)

Re:Using prime numbers to make better backgrounds by skymt on Thursday April 07, 2011 @12:18PM (#2420043)
The experimental-music band Bull of Heaven recently released a prime-looping generative piece that they project will last 8,462,937,602,125,701,219,674,955.2362595095 years before repeating.

http://bullofheaven.com/media/260.html

Re:Using prime numbers to make better backgrounds by mullr on Thursday April 07, 2011 @10:34AM (#2419587)
They're also useful for reverb effects, in very much the same way. See http://www.npr.org/2010/08/03/128935865/queens-brian-may-roc... (under "On The 'Stomp-Stomp-Clap' Section Of 'We Will Rock You'")

Also, I think the technique will work as long as the numbers are relatively prime, which may be a bit easier to design around.

Re:Using prime numbers to make better backgrounds by camtarn on Thursday April 07, 2011 @11:22AM (#2419798)
Using coprime-length looping rhythms on top of each other can also create some pretty interesting sounds.

Take a rhythm in 4/4 (say a standard rock snare backbeat, playing on the second and fourth note of a four note bar), layer on a cymbal pattern which repeats every three notes, then a bass drum pattern which repeats every five notes. The effect is fairly subtle because the snare keeps everything sounding like 4/4, but the feel of the rhythm is constantly shifting.

I found a nice YouTube video demonstrating this a while back, but unfortunately all I can find now is videos of polyrhythms where the loops all have the same duration but different numbers of beats per duration... which is an interesting technique in and of itself :)

Re:Using prime numbers to make better backgrounds by adavies42 on Thursday April 07, 2011 @04:10PM (#2421025)
Holy shit, Brian May's one more Ph.D. away from being Buckaroo Banzai!
Re:Using prime numbers to make better backgrounds by granite_scones on Thursday April 07, 2011 @12:13PM (#2420007)
"This example uses the simplest possible set of prime number — 1, 3, and 7."

1 is not a prime number. Also, the "simplest" possible set of primes would be 2, 3, and 5.

Re:Using prime numbers to make better backgrounds by SeanLuke on Thursday April 07, 2011 @11:18AM (#2419785)
What's wrong with the "cicada theory"

1. The most common cicadas come out every year or every other year.

2. The 17-year cicadas (for example) don't come out once every 17 years -- they come out every single year. Just in different broods (groups differing by phase). Some broods are much bigger than others of course, and broods are often located in different parts of the country, but many broods can and do overlap.

So I dunno. I'm guessing they're 13 and 17 year cicadas because that's how long it takes to develop.

Re:Using prime numbers to make better backgrounds by scott_s on Thursday April 07, 2011 @05:40PM (#2421311)
I'm guessing they're 13 and 17 year cicadas because that's how long it takes to develop.

That's a tautology. "A baby takes 9 months to be born because that's how long it takes to develop." Well, yes, but the question becomes, why does it take that amount of time to develop? Were there direct selection pressures acting on that length of time, or is that length of time mostly a function of other variables which are acted on directly by selection pressure?

Re:Using prime numbers to make better backgrounds by KirinDave on Thursday April 07, 2011 @11:58AM (#2419946)
Consider, though, that these groups of cicadas don't really "care" about one another from a genetic standpoint. If the broods don't interact, they're basically different sets of genes that only interact via mutations, so the principle still holds.

What's interesting about that is how the broods might diverge to coprime emergence schedules to prevent competition.

Re:Using prime numbers to make better backgrounds by ars on Thursday April 07, 2011 @06:38PM (#2421508)
Well, they do care. The idea is to starve out predators. If there is another set of cicadas feeding them, then it doesn't work for just you to avoid them.
Re:Using prime numbers to make better backgrounds by scott_s on Friday April 08, 2011 @10:15AM (#2423873)
KirinDave's point is that there is no "idea." If the groups are disjoint, there's no conspiracy, no way for them to interact with each other. If you and your group avoid the predators, then you will thrive. It doesn't matter that another group does not. Evolution happens at the level of genes, not groups.
Re:Using prime numbers to make better backgrounds by Nate75Sanders on Thursday April 07, 2011 @06:20PM (#2421456)
While not the same thing, the concept of increasing the degree of realism/getting away from things that are too regular reminded me of Perlin Noise: http://en.wikipedia.org/wiki/Perlin_noise
Re:Using prime numbers to make better backgrounds by jws on Thursday April 07, 2011 @11:08AM (#2419731)
I won't get a chance to write this up, but in a similar vein, if you split the grain/texture off of an image, you can scale and stretch the image as needed, then drop a fairly small, tiled grain texture back on top. I think it is nicer to do two grain textures, one for lighter and one for darker. Make the grain image be solid white or black and put the grain in the alpha channel.
Re:Using prime numbers to make better backgrounds by xbot on Thursday April 07, 2011 @08:17PM (#2421830)
Hey guys, I actually mocked up a woodgrain test page while I was developing the article but I ended up preferring the lego and curtain examples. But if your interested:

http://www.sitepoint.com/examples/primes/woodgrain.html

It's not bad, but I don't think it's killer yet.

I've got a very raw maze generation example somewhere if anyone's interested.

Re:Using prime numbers to make better backgrounds by prawn on Friday April 08, 2011 @12:24AM (#2422448)
This is HN. Almost everyone's interested, so post away!
Re:Using prime numbers to make better backgrounds by xbot on Friday April 08, 2011 @08:59PM (#2426158)
http://www.sitepoint.com/examples/primes/maze.html

The graphics are a bit nasty but the concept is works. There seems to be a diagonal pattern emerging, but a fourth layer would certainly break that.

Re:Using prime numbers to make better backgrounds by mcdaid on Thursday April 07, 2011 @10:53AM (#2419661)
Brilliant interesting article about a very simple but clever idea. I am not sure if I would use this css background technique, but the lego example is brilliant.

Some articles trigger lots of ideas in my mind, this was one of them.

Re:Using prime numbers to make better backgrounds by harshpotatoes on Thursday April 07, 2011 @02:11PM (#2420513)
And some people still question the value of pure math. These design tricks would anger some of my design friends, who still believe you can be left brain OR right brain.
Re:Using prime numbers to make better backgrounds by TimothyBurgess on Thursday April 07, 2011 @06:05PM (#2421402)
Yeah what's up with that?! I think in this day and age people are more than capable of being both highly creative and logical.
Re:Using prime numbers to make better backgrounds by hydrazine on Thursday April 07, 2011 @10:51AM (#2419651)
Gonna try this with pseudo-random opacity styling for even more variations.
Re:Using prime numbers to make better backgrounds by mikesurowiec on Thursday April 07, 2011 @10:45AM (#2419623)
Wow, very impressive! I will definitely be trying this out. It reminded me of my discrete mathematics class, so now I'm wondering if there are any other cool principles that can be applied to design
Re:Using prime numbers to make better backgrounds by kylemaxwell on Thursday April 07, 2011 @11:08AM (#2419732)
Fair point, it's really basic combinatorics but well applied and properly executed.
Re:Using prime numbers to make better backgrounds by euccastro on Thursday April 07, 2011 @08:19PM (#2421837)
And number theory.
Re:Using prime numbers to make better backgrounds by alsomike on Thursday April 07, 2011 @07:46PM (#2421728)
892 unique ways to partition a 3x4 grid: http://www.dubberly.com/concept-maps/3x4grid.html

They also have an interactive tool that generates HTML/CSS: http://www.3x4grid.com

Re:Using prime numbers to make better backgrounds by joubert on Friday April 08, 2011 @07:08AM (#2423235)
Reminds me of a section in The Blind Watchmaker on cicadas and convergence in evolution - http://books.google.com/books?id=sPpaZnZMDG0C&pg=PA100&#...
Re:Using prime numbers to make better backgrounds by thascales on Thursday April 07, 2011 @10:27AM (#2419557)
Simple, elegant, effective. I know how I'm spending my evening...
Re:Using prime numbers to make better backgrounds by exch on Thursday April 07, 2011 @10:18AM (#2419521)
There's a typo in the title of the second 'chapter'.

"That’s great. But wa/s/ has all this got to do with web design?"

Re:Using prime numbers to make better backgrounds by xbot on Friday April 08, 2011 @08:54PM (#2426153)
Ah, well spotted. Fixed! Thanks for that.
Re:Using prime numbers to make better backgrounds by jeberle on Saturday April 09, 2011 @12:02PM (#2427389)
Why is it that "design" sites have the worst design? Yes, please be sure to destroy the page margins, and set a min width on the page so that I have to scroll horizontally to read the end of lines. Classic.