ONE-LINERS: Grow a picture or video from a single line of C or Python code |
abs(y) >= 5 ? 40*cos(x/15) : -10 Induced grating illusion The grey strip across the middle is a single flat shade of grey |
|
y & 8 ? (x > -80 && x < -20 ? green : white) : (x > 20 && x < 80 ? green: black) Munker-White illusion The two greens are the same green |
|
(((x+24) & 24) == 24)&&(((x+y) & 12) == 12)&&(((x & 32)!=0)*green | ((x & 64)!=0)*red | (x > 0)*blue) Tracks or streamers |
|
(x*x+y*y > 60*60) ? (1+cos((sqrt(x*x+y*y))/17.0))*red + (1+cos((sqrt(x*x+y*y))/17.0))*(green*(abs(y+x))/256) : black Ring |
|
((x & y) >> (x & ~y & 127))*green + ((x & y) >> (~x & y & 31))*red + ((x & y) >> (x & y & 63))*blue Sierpinski-like Carpet Many variations possible by changing the numbers. For each colour, try 3, 7, 15, 31, 63, 127. These preserve a different number of low-order bits for the shift operation. |
|
sqrt(2*(x*x+y*y) - 2*sqrt(x*x+y*y)*(x*cos(sqrt(x*x+y*y)/5.0)+y*sin(sqrt(x*x+y*y)/5.0))) A kind of spiral |
|
green*sqrt(2*(x*x+y*y) - 2*sqrt(x*x+y*y)*(x*cos(sqrt(x*x+y*y)/20.0)+y*sin(sqrt(x*x+y*y)/20.0)))+red*sqrt(2*(x*x+y*y) - 2*sqrt(x*x+y*y)*(x*cos(sqrt(x*x+y*y)/30.0)+y*sin(sqrt(x*x+y*y)/30.0)))+blue*sqrt(2*(x*x+y*y) - 2*sqrt(x*x+y*y)*(x*cos(sqrt(x*x+y*y)/10.0)+y*sin(sqrt(x*x+y*y)/10.0))) A more colourful one |
|
(x/80)*(x/80) + (-(y-30)/60 - pow(((x/80)*(x/80)),1/3))*(-(y-30)/60-pow(((x/80)*(x/80)),1/3)) < 1 ? red : white Heart |
|
sin(sin(x/12)+cos(y/12))-cos(sin(x*y/144)+cos(x/12)) Sine/cosine mix |
|
abs(sin(x/30))*(red*abs(sin((x+y)/10))+blue*abs(sin((x-y)/10))) Tartan rolls |
|
((x & 12) == 0)*(((x+60)*(x+60)+y*y<40*40) ? 0.7*white : red) + ((x & 12) == 4)*(((x-60)*(x-60)+y*y<40*40) ? 0.7*white : blue) + ((x & 12) == 8)*(((x+60)*(x+60)+y*y<40*40) ? 0.7*white : (blue+red)) + ((x & 12) == 12)*(((x-60)*(x-60)+y*y<40*40) ? 0.7*white : green) The confetti illusion Under the stripes, both disks are the same colour. |
|
(abs(y)>60)||(abs(y) == 30)||(abs(y)<60&&((y==x)||(y==2*x)||(2*y==x)||(3*y==x)||(4*y==x)||(6*y==x)||(y==-x)||(y==-2*x)||(2*y==-x)||(3*y==-x)||(4*y==-x)||(6*y==-x))) Hering illusion If you want joined up lines you can convert '6*y==x' to 'y==(int)(x/6)' for example, but I like the dashed lines. |
|
-cos((sqrt(sqrt(((x-50)-(y+80))*((x-50)-(y+80))+(y+80)*(y+80))))/0.9)*red+cos((sqrt(sqrt(((x-50)-(y+80))*((x-50)-(y+80))+(y+80)*(y+80))))/1.5)*green+cos((sqrt(sqrt(((x-50)-(y+80))*((x-50)-(y+80))+(y+80)*(y+80))))/0.40)*blue One-liners get much longer when you offset from the origin! |
|
(x & 31 == 15)*(x + y & 63 > 24) ? (y+129)*(3 + (x + y & 63 > 54))*abs(sin(x/45)) : 127-y A sense of falling like an arrow shower sent out of sight, somewhere becoming rain. (Larkin) |
|
((y & 15 > 8)*(x + (y-15) & 31 > 16)*0.5 + (y & 15 < 8)*(x - y & 31 > 16))*green Blocks or chevrons? |
|
((y>0)&&((x-20 < 0.5*y && -x-20 < 0.5*y)*((int(1000/y))%6 ? blue*0.2 : blue*0.25+red*0.1) + (x-20>=0.5*y || -x-20>=0.5*y)*(blue*0.15)))+((y<=0)&&((x*x+y*y<20*20)*(red*0.8+green*0.4) + (x*x+y*y>=20*20)*((rand()%1000==0)*green*0.9 + red*((128+y)/256)))) + 0.3*(rand()%1000) Grainy Sunset |
|
0.175*x*x + 0.25981*x*y + 0.325*y*y >= 1800 ? white : 0.175*x*x + 0.25981*x*y + 0.325*y*y >= 300 ? white*0.1 : 0.175*x*x + 0.25981*x*y + 0.325*y*y >= 3 ? red : black Vinyl |
|
(abs(x) > 50 || abs(y) > 50) ? (1+cos(sqrt(sqrt(x*x*x*x*x*x+y*y*y*y*y*y))/150.0))*blue : black Blue Neon |
|
(y < -85-10)*((x < -86-10 || (x >= -86+10 && x < 0))*red + ((x >= -86-10&&x < -86-5)||(x >= -86+5&&x<-86+10))*white + (x >=-86-5&&x<-86+5)*blue) + (y>=-85-10&&y<-85-5)*((x < -86-5 || (x >= -86+5 && x < 0))*white + (x >=-86-5&&x<-86+5)*blue) + (y>=-85-5&&y<-85+5)*(x<0)*blue + (y>=-85+5&&y<-85+10)*((x < -86-5 || (x >= -86+5 && x < 0))*white + (x >=-86-5&&x<-86+5)*blue) + (y>=-85+10&&y<-43)*((x < -86-10 || (x >= -86+10 && x < 0))*red + ((x >= -86-10&&x < -86-5)||(x >= -86+5&&x<-86+10))*white + (x >=-86-5&&x<-86+5)*blue) + ((y>=43&&y<85-7)||(y>=85+7))*((x<-86-7||(x>=-86+7&&x<0))*blue + (x>=-86-7&&x<-86+7)*(red+green)) + (y>=85-7&&y<85+7)*(x<0)*(red+green) + ((y>=-43&&y<0-7)||(y>=0+7&&y<43))*(((x>=0&&x<42-7)||(x>=42+7))*red + ((x>=42-7)&&(x<42+7))*white) + (y>=0-7&&y<0+7)*(x>=0)*white Scandinavia I was going to do Finland, Iceland and the Faroes too, but this got long enough! |
|
(y<-50 || (y >= -34 && y < 50))*((x<-70)*white + (x>-60)*red)+(y>=-50 && y < -34 && x > -60)*red + (y>60)*((x<-70)*blue + (x>-60 && x<90)*white+ ((x>100)*((y<90)*white + (y>100)*(red+green)))) Composition II in Red, Blue and Yellow. Piet Mondrian, 1930. |
|
cos(sqrt(sqrt(x*x*x*x*x*x+y*y*y*y*y*y))/800.0)*blue + cos(sqrt(sqrt(x*x*x*x*x*x+y*y*y*y*y*y))/1500.0)*green Square 1 |
|
cos(sqrt(sqrt(x*x*x*x*x*x+y*y*y*y*y*y))/800.0)*blue + cos(sqrt(sqrt(x*x*x*x*x*x+y*y*y*y*y*y))/1500.0)*red Square 2 |
|
cos(x*x/250.0) * cos(y*y/250.0) > 0.3 ? (red+green)*(cos(x*x/250.0) * cos(y*y/250.0)) + 0.07*blue*(sqrt(sqrt(x*x+y*y))) : black Square in the middle |
|
(!(x||y) ? 2 : sin(sqrt(x*x+y*y)/6)/(sqrt(x*x+y*y)/6)+1) + ((x!=0)?(128*sin(x/6)/(x/6)<-y):0) Quick intermission for signal/image processing types sinc function from above and the side. |
|
(x*x+y*y < 154*154)*((1+sin((sqrt((x+40)*(x+40)+y*y/1.5)/25-pi/2)))*red + (1+sin((sqrt((x-40)*(x-40)+y*y/1.5)/25-pi/2)))*green) Ovals |
|
x != 0 && x & 3 == 3 && ((y-50*sin(x/8.0))*(y-50*sin((x-1)/8.0))<0 && green || white) Shimmering Sine Wave I can't decide if I've created a new illusion or just an annoying picture. |
|
sqrt(4*sqrt(x*x*x*x+y*y*y*y) - 2*sqrt(sqrt(x*x*x*x+y*y*y*y))*(x*cos(sqrt(sqrt(x*x*x*x+y*y*y*y))/8.0)+y*sin(sqrt(sqrt(x*x*x*x+y*y*y*y))/8.0)))*red A rose perhaps |
|
sqrt((x+y^x-y<<1)&x*x+y*y>>6) by Marco Bodrato, who comments that it's reminiscent of The Alchemist by Remedios Varo Probably my favourite monochrome one-liner. Except... |
|
sqrt((x+y^x-(y<<1))&x*x+y*y>>6) Just to show what a change of precedence can do. The same string as Marco's directly above, but with the insertion of one pair of brackets. I think maybe I prefer this one. |
|
(int)(sin(x/10.1)+cos(y/10.1))&(x+y) By Stefano Bodrato |
|
((y<-30 && x<-10)&&((int)(y/3)%2?blue:(int)(x/3)%2?blue:red+green))+((y>=-30 || x>=-10)*(((int)(((y+128)/12))%2)*(blue+green) + red)) By Stefano Bodrato |
|
cos(x*x+y*y) By Stefano Bodrato |
|
(y>x*x/30-100)?x+128+red*y:128-blue*y By Stefano Bodrato |
|
(sqrt(x*x+y*y)>30)*(((sin(x/10.1)>y/10.1))*(red*abs(x-y)*abs(sin(x+y/10))*abs(x+y))+((sin(x/10.1)<=y/10.1)*(3000*blue*(sin(x/20.1))))) + (sqrt(x*x+y*y)<=30)*(50*(x*white+y*red)) By Stefano Bodrato |
|
green * ((((x - 50)*(x - 50) + (y - 25)*(y - 25)) > 8000 ? 8000 : ((x - 50)*(x - 50) + (y - 25)*(y - 25)))) + blue * ((((x + 50)*(x + 50) + (y - 25)*(y - 25)) > 8000 ? 8000 : ((x + 50)*(x + 50) + (y - 25)*(y - 25)))) + red * ((((x - 0)*(x - 0) + (y + 25)*(y + 25)) > 8000 ? 8000 : ((x - 0)*(x - 0) + (y + 25)*(y + 25)))) By GDR! |
|
green*sin(((x - 50)*(x - 50) + y*y) / 300) + blue*sin(((x + 50)*(x + 50) + y*y) / 300) + red * sin((x * x + (y - 50) * (y - 50)) / 300) By GDR! |
|
(int)(81.0 * atan2(x, y)) ^ (int)(2.0 * sqrt(x*x + y*y)) By GDR! |
|
blue*(pow((((int)(81.0 * atan2(x, y))) & 31) - 15, 2) + pow((((int)(2.0 * sqrt(x*x + y*y))) & 31) - 15, 2)) By GDR! |
|
((abs((int)(81.0 * atan2(x, y))) %100)- 50)*((abs((int)(81.0 * atan2(x, y))) %100)- 50) + ((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50)*((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50) > 41*41 ? white : ((abs((int)(81.0 * atan2(x, y))) %100)- 50)*((abs((int)(81.0 * atan2(x, y))) %100)- 50) + ((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50)*((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50) >= 40*40 || (((abs((int)(81.0 * atan2(x, y))) %100)- 50)+15)*(((abs((int)(81.0 * atan2(x, y))) %100)- 50)+15)+(((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50)+10)*(((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50)+10) < 6* 6 || (((abs((int)(81.0 * atan2(x, y))) %100)- 50)-15)*(((abs((int)(81.0 * atan2(x, y))) %100)- 50)-15)+(((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50)+10)*(((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50)+10) < 6* 6 || ((abs((int)(81.0 * atan2(x, y))) %100)- 50)*((abs((int)(81.0 * atan2(x, y))) %100)- 50) + (((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50)+15)*(((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50)+15) >= 40*40 && ((abs((int)(81.0 * atan2(x, y))) %100)- 50)*((abs((int)(81.0 * atan2(x, y))) %100)- 50)+(((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50)+15)*(((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50)+15)<=41*41 && ((abs((int)(2.0 * sqrt(x*x + y*y))) %100) - 50) > 15 ? 0 : red + green By GDR! |
|
((x ^ y) >> (-x & ~y & 2))*green + ((x ^ y) >> (-x & y & 122))*red + ((x ^ y) >> (-x & y & 36))*blue Another carpet to finish |
Send your contributions to the gallery by emailing me at johnatuserportdotcom!