Create some Tweetable Mathematical Art.
unsigned short RD( int i, int j ) { return 1023; } unsigned short GR( int i, int j ) { return 0; } unsigned short BL( int i, int j ) { return 0; }
unsigned short RD( int i, int j ) { return i; } unsigned short GR( int i, int j ) { return i; } unsigned short BL( int i, int j ) { return j; }
Credit:
teh internets is made of catz
https://codegolf.stackexchange.com/users/11744/teh-internets-is-made-of-catzint t[64],k=0,l,e,d=2e7;srand(time(0));while(k<64){t[k]=rand()%DIM;if((e=_sq(i-t[k])+_sq(j-t[42&k++]))<d)d=e,l=k;}return t[l];
static int t[64];int k=0,l,e,d=2e7;while(k<64){if(!t[k])t[k]=rand()%DIM;if((e=_sq(i-t[k])+_sq(j-t[42&k++]))<d)d=e,l=k;}return t[l];
static int t[64];int k=0,l,e,d=2e7;while(k<64){if(!t[k])t[k]=rand()%DIM;if((e=_sq(i-t[k])+_sq(j-t[42&k++]))<d)d=e,l=k;}return t[l];
(127 chars, 132 chars, 132 chars)
3 superimposed "Voronoi" diagrams
unsigned short RD( int i, int j ) { int t[64], // coords of 64 sites k=0, // loop counter l, // index of closest site e, // temporary d=2e7; // distance to closest
hacks while(k<64){ // For each point hacks that set up t[k]s if( // if shorter distance ( e = _sq( i - t[k] ) + _sq( j - hack ) ) < d ) d=e, // store distance l=k; // and remember index }
// l is the index of the // closest site. Return // the colour of that site. return t[l] }
unsigned short GR( int i, int j ) { unsigned short BL( int i, int j ) { // Both same as red // (except for hacks)
int t[64],k=0,l,e,d=2e7; // At the start of every call to RD // reset the random seed. // This gets us the same sites // every time without storing them. srand(time(0)); while(k<64) // Just hope we don't cross // a second boundary!
while(k<64){ // Then the x coord is made // by a call to rand() t[k]=rand()%DIM; if((e=_sq(...
if( ( e = _sq( i - t[k] ) + _sq( j - t[42&k++]) ) < d ) // The y coord is the x coord of // the site with index m, where // m = 00101010 & k // Note m <= k, so // t[m] is initialised.
) < d ) d=e, // comma avoids needing l=k; // {} around these. }
d=e, l=k; } // The colour we return is // the x coord of the site return t[l]; }
Credit: githubphagocyte
Credit: user11153 (183 bytes over)
Credit: FireFly
Credit: cjfaure
Credit: squeamish ossifrage
Credit: FireFly
Patreon! | patreon.com/andybalaam |
---|---|
Videos | youtube.com/user/ajbalaam |
@andybalaam | |
Blog | artificialworlds.net/blog |
Projects | artificialworlds.net |