Skip to main content
Mod Removes Wiki by Doorknob
Post Undeleted by Martin Ender
added 214 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

(This isn't entirelyEdit: This is now a valid because C++ doesn't allow nested functions. Seeanswer, thanks to the code belowforward declarations of GR and BL.)

Now for the (not quite valid) code. I need the recursive function to compute the sequence, which I can't put inside the colour functions, unfortunately. However, ifTo do that I use did add the length of the preliminary codeRD whenever j is negative. Unfortunately, that does not leave enough characters to each ofcompute the function bodiesred channel value itself, they would be 139 bytes each:so RD in turn calls GR with an offset to produce the red channel.

int h[1000];
int f(int n){if(!h[n])h[n]=n<2?1:f(n-f(n-1))+f(n-f(n-2));returnunsigned h[n];}
charshort red_fnRD(int i,int j){
    returnstatic 256-f(sqrt(int h[1000];return j<0?h[i]?h[i]:h[i]=i<2?1:RD(i-256)*RD(i-2561,j)+(,j-256)*+RD(ji-256RD(i-2,j),j)/2.9:GR(i+256,j+512);
}
charunsigned green_fnshort GR(int i,int j){
    return 256DIM-f4*RD(sqrt((i-512)*(i-512)+(j-768)*(j-768))/2.9,-1);
}
charunsigned blue_fnshort BL(int i,int j){
    return 256DIM-f4*RD(sqrt((i-768)*(i-768)+(j-256)*(j-256))/2.9,-1);
}

Of course, this is pretty much the simplest possible usage of the sequence, and there are loads of characters left. Feel free to borrow it and do other crazy things with it!

Here is another version where the boundary and the colours are determined by the Q-sequence. In this case, there was enough room in RD so that I didn't even need the forward declaration:

charunsigned red_fnshort RD(int i,int j){
    returnstatic 2*fint h[1024];return j<0?h[i]?h[i]:h[i]=i<2?1:RD(i)-i+512>1023RD(i-1,j?f),j)+RD(i)/-RD(i-2.4,j),j):fRD(2*RD(i,-1)-i+512>1023-j?i:1023-i,-1)/20.4;6;
}
charunsigned green_fnshort GR(int i,int j){
    return red_fnRD(i, j);
}
charunsigned blue_fnshort BL(int i,int j){
    return red_fnRD(i, j);
}

(This isn't entirely valid because C++ doesn't allow nested functions. See the code below.)

Now for the (not quite valid) code. I need the recursive function to compute the sequence, which I can't put inside the colour functions, unfortunately. However, if I did add the length of the preliminary code to each of the function bodies, they would be 139 bytes each:

int h[1000];
int f(int n){if(!h[n])h[n]=n<2?1:f(n-f(n-1))+f(n-f(n-2));return h[n];}
char red_fn(int i,int j){
    return 256-f(sqrt((i-256)*(i-256)+(j-256)*(j-256))/2.9);
}
char green_fn(int i,int j){
    return 256-f(sqrt((i-512)*(i-512)+(j-768)*(j-768))/2.9);
}
char blue_fn(int i,int j){
    return 256-f(sqrt((i-768)*(i-768)+(j-256)*(j-256))/2.9);
}

Of course, this is pretty much the simplest possible usage of the sequence. Feel free to borrow it and do other crazy things with it!

Here is another version where the boundary and the colours are determined by the Q-sequence.

char red_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}
char green_fn(int i,int j){
    return red_fn(i, j);
}
char blue_fn(int i,int j){
    return red_fn(i, j);
}

Edit: This is now a valid answer, thanks to the forward declarations of GR and BL.

Now for the code. I need the recursive function to compute the sequence. To do that I use RD whenever j is negative. Unfortunately, that does not leave enough characters to compute the red channel value itself, so RD in turn calls GR with an offset to produce the red channel.

unsigned short RD(int i,int j){
    static int h[1000];return j<0?h[i]?h[i]:h[i]=i<2?1:RD(i-RD(i-1,j),j)+RD(i-RD(i-2,j),j):GR(i+256,j+512);
}
unsigned short GR(int i,int j){
    return DIM-4*RD(sqrt((i-512)*(i-512)+(j-768)*(j-768))/2.9,-1);
}
unsigned short BL(int i,int j){
    return DIM-4*RD(sqrt((i-768)*(i-768)+(j-256)*(j-256))/2.9,-1);
}

Of course, this is pretty much the simplest possible usage of the sequence, and there are loads of characters left. Feel free to borrow it and do other crazy things with it!

Here is another version where the boundary and the colours are determined by the Q-sequence. In this case, there was enough room in RD so that I didn't even need the forward declaration:

unsigned short RD(int i,int j){
    static int h[1024];return j<0?h[i]?h[i]:h[i]=i<2?1:RD(i-RD(i-1,j),j)+RD(i-RD(i-2,j),j):RD(2*RD(i,-1)-i+512>1023-j?i:1023-i,-1)/0.6;
}
unsigned short GR(int i,int j){
    return RD(i, j);
}
unsigned short BL(int i,int j){
    return RD(i, j);
}
Post Deleted by Martin Ender
deleted 60 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

(This isn't entirely valid because C++ doesn't allow nested functions. See the code below.)

Having fun with Hofstadter's Q-sequence! If we're using the radial distance from some point as the input and the output as the inverse colour, we get something which looks like coloured vinyl.

enter image description here

The sequence is very similar to the Fibonacci sequence, but instead of going 1 and 2 steps back in the sequence, you take the two previous values to determine how far to go back before taking the sum. It grows roughly linear, but every now and then there's a burst of chaos (at increasing intervals) which then settles down to an almost linear sequence again before the next burst:

enter image description here

You can see these ripples in the image after regions which look very "flat" in colour.

Of course, using only one colour is boring.

enter image description here

Now for the (not quite valid) code. I need the recursive function to compute the sequence, which I can't put inside the colour functions, unfortunately. However, if I did add the length of the preliminary code to each of the function bodies, they would be 139 bytes each:

int h[1000];
int f(int n){if(!h[n])h[n]=n<2?1:f(n-f(n-1))+f(n-f(n-2));return h[n];}
char red_fn(int i,int j){
    return 256-f(sqrt((i-256)*(i-256)+(j-256)*(j-256))/2.9);
}
char green_fn(int i,int j){
    return 256-f(sqrt((i-512)*(i-512)+(j-768)*(j-768))/2.9);
}
char blue_fn(int i,int j){
    return 256-f(sqrt((i-768)*(i-768)+(j-256)*(j-256))/2.9);
}

Of course, this is pretty much the simplest possible usage of the sequence. Feel free to borrow it and do other crazy things with it!

Here is another version where the boundary and the colours are determined by the Q-sequence.

char red_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}
char green_fn(int i,int j){
    return 2*fred_fn(i)-i+512>1023-, j?f(i)/2.4:f(1023-i)/2.4;;
}
char blue_fn(int i,int j){
    return 2*fred_fn(i)-i+512>1023-, j?f(i)/2.4:f(1023-i)/2.4;;
}

enter image description here

(This isn't entirely valid because C++ doesn't allow nested functions. See the code below.)

Having fun with Hofstadter's Q-sequence! If we're using the radial distance from some point as the input and the output as the inverse colour, we get something which looks like coloured vinyl.

enter image description here

The sequence is very similar to the Fibonacci sequence, but instead of going 1 and 2 steps back in the sequence, you take the two previous values to determine how far to go back before taking the sum. It grows roughly linear, but every now and then there's a burst of chaos (at increasing intervals) which then settles down to an almost linear sequence again before the next burst:

enter image description here

You can see these ripples in the image after regions which look very "flat" in colour.

Of course, using only one colour is boring.

enter image description here

Now for the (not quite valid) code. I need the recursive function to compute the sequence, which I can't put inside the colour functions, unfortunately. However, if I did add the length of the preliminary code to each of the function bodies, they would be 139 bytes each:

int h[1000];
int f(int n){if(!h[n])h[n]=n<2?1:f(n-f(n-1))+f(n-f(n-2));return h[n];}
char red_fn(int i,int j){
    return 256-f(sqrt((i-256)*(i-256)+(j-256)*(j-256))/2.9);
}
char green_fn(int i,int j){
    return 256-f(sqrt((i-512)*(i-512)+(j-768)*(j-768))/2.9);
}
char blue_fn(int i,int j){
    return 256-f(sqrt((i-768)*(i-768)+(j-256)*(j-256))/2.9);
}

Of course, this is pretty much the simplest possible usage of the sequence. Feel free to borrow it and do other crazy things with it!

Here is another version where the boundary and the colours are determined by the Q-sequence.

char red_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}
char green_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}
char blue_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}

enter image description here

(This isn't entirely valid because C++ doesn't allow nested functions. See the code below.)

Having fun with Hofstadter's Q-sequence! If we're using the radial distance from some point as the input and the output as the inverse colour, we get something which looks like coloured vinyl.

enter image description here

The sequence is very similar to the Fibonacci sequence, but instead of going 1 and 2 steps back in the sequence, you take the two previous values to determine how far to go back before taking the sum. It grows roughly linear, but every now and then there's a burst of chaos (at increasing intervals) which then settles down to an almost linear sequence again before the next burst:

enter image description here

You can see these ripples in the image after regions which look very "flat" in colour.

Of course, using only one colour is boring.

enter image description here

Now for the (not quite valid) code. I need the recursive function to compute the sequence, which I can't put inside the colour functions, unfortunately. However, if I did add the length of the preliminary code to each of the function bodies, they would be 139 bytes each:

int h[1000];
int f(int n){if(!h[n])h[n]=n<2?1:f(n-f(n-1))+f(n-f(n-2));return h[n];}
char red_fn(int i,int j){
    return 256-f(sqrt((i-256)*(i-256)+(j-256)*(j-256))/2.9);
}
char green_fn(int i,int j){
    return 256-f(sqrt((i-512)*(i-512)+(j-768)*(j-768))/2.9);
}
char blue_fn(int i,int j){
    return 256-f(sqrt((i-768)*(i-768)+(j-256)*(j-256))/2.9);
}

Of course, this is pretty much the simplest possible usage of the sequence. Feel free to borrow it and do other crazy things with it!

Here is another version where the boundary and the colours are determined by the Q-sequence.

char red_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}
char green_fn(int i,int j){
    return red_fn(i, j);
}
char blue_fn(int i,int j){
    return red_fn(i, j);
}

enter image description here

added 478 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

(This isn't entirely valid because C++ doesn't allow nested functions. See the code below.)

Having fun with Hofstadter's Q-sequence! If we're using the radial distance from some point as the input and the output as the inverse colour, we get something which looks like coloured vinyl.

enter image description here

The sequence is very similar to the Fibonacci sequence, but instead of going 1 and 2 steps back in the sequence, you take the two previous values to determine how far to go back before taking the sum. It grows roughly linear, but every now and then there's a burst of chaos (at increasing intervals) which then settles down to an almost linear sequence again before the next burst:

enter image description here

You can see these ripples in the image after regions which look very "flat" in colour.

Of course, using only one colour is boring.

enter image description here

Now for the (not quite valid) code. I need the recursive function to compute the sequence, which I can't put inside the colour functions, unfortunately. However, if I did add the length of the preliminary code to each of the function bodies, they would be 139 bytes each:

int h[1000];
int f(int n){if(!h[n])h[n]=n<2?1:f(n-f(n-1))+f(n-f(n-2));return h[n];}
char red_fn(int i,int j){
    return 256-f(sqrt((i-256)*(i-256)+(j-256)*(j-256))/2.9);
}
char green_fn(int i,int j){
    return 256-f(sqrt((i-512)*(i-512)+(j-768)*(j-768))/2.9);
}
char blue_fn(int i,int j){
    return 256-f(sqrt((i-768)*(i-768)+(j-256)*(j-256))/2.9);
}

Of course, this is pretty much the simplest possible usage of the sequence. Feel free to borrow it and do other crazy things with it!

Here is another version where the boundary and the colours are determined by the Q-sequence.

char red_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}
char green_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}
char blue_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}

enter image description here

(This isn't entirely valid because C++ doesn't allow nested functions. See the code below.)

Having fun with Hofstadter's Q-sequence! If we're using the radial distance from some point as the input and the output as the inverse colour, we get something which looks like coloured vinyl.

enter image description here

The sequence is very similar to the Fibonacci sequence, but instead of going 1 and 2 steps back in the sequence, you take the two previous values to determine how far to go back before taking the sum. It grows roughly linear, but every now and then there's a burst of chaos (at increasing intervals) which then settles down to an almost linear sequence again before the next burst:

enter image description here

You can see these ripples in the image after regions which look very "flat" in colour.

Of course, using only one colour is boring.

enter image description here

Now for the (not quite valid) code. I need the recursive function to compute the sequence, which I can't put inside the colour functions, unfortunately. However, if I did add the length of the preliminary code to each of the function bodies, they would be 139 bytes each:

int h[1000];
int f(int n){if(!h[n])h[n]=n<2?1:f(n-f(n-1))+f(n-f(n-2));return h[n];}
char red_fn(int i,int j){
    return 256-f(sqrt((i-256)*(i-256)+(j-256)*(j-256))/2.9);
}
char green_fn(int i,int j){
    return 256-f(sqrt((i-512)*(i-512)+(j-768)*(j-768))/2.9);
}
char blue_fn(int i,int j){
    return 256-f(sqrt((i-768)*(i-768)+(j-256)*(j-256))/2.9);
}

Of course, this is pretty much the simplest possible usage of the sequence. Feel free to borrow it and do other crazy things with it!

(This isn't entirely valid because C++ doesn't allow nested functions. See the code below.)

Having fun with Hofstadter's Q-sequence! If we're using the radial distance from some point as the input and the output as the inverse colour, we get something which looks like coloured vinyl.

enter image description here

The sequence is very similar to the Fibonacci sequence, but instead of going 1 and 2 steps back in the sequence, you take the two previous values to determine how far to go back before taking the sum. It grows roughly linear, but every now and then there's a burst of chaos (at increasing intervals) which then settles down to an almost linear sequence again before the next burst:

enter image description here

You can see these ripples in the image after regions which look very "flat" in colour.

Of course, using only one colour is boring.

enter image description here

Now for the (not quite valid) code. I need the recursive function to compute the sequence, which I can't put inside the colour functions, unfortunately. However, if I did add the length of the preliminary code to each of the function bodies, they would be 139 bytes each:

int h[1000];
int f(int n){if(!h[n])h[n]=n<2?1:f(n-f(n-1))+f(n-f(n-2));return h[n];}
char red_fn(int i,int j){
    return 256-f(sqrt((i-256)*(i-256)+(j-256)*(j-256))/2.9);
}
char green_fn(int i,int j){
    return 256-f(sqrt((i-512)*(i-512)+(j-768)*(j-768))/2.9);
}
char blue_fn(int i,int j){
    return 256-f(sqrt((i-768)*(i-768)+(j-256)*(j-256))/2.9);
}

Of course, this is pretty much the simplest possible usage of the sequence. Feel free to borrow it and do other crazy things with it!

Here is another version where the boundary and the colours are determined by the Q-sequence.

char red_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}
char green_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}
char blue_fn(int i,int j){
    return 2*f(i)-i+512>1023-j?f(i)/2.4:f(1023-i)/2.4;
}

enter image description here

added 2 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975
Loading
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975
Loading