[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 44 KB, 500x500, art.png [View same] [iqdb] [saucenao] [google]
9588874 No.9588874 [Reply] [Original]

Challenge:
You will have 3 functions:
getRed(i, j)
getGreen(i, j)
getBlue(i, j)
Where i and j are the xy coordinate where the pixel color will be.
Your goal is to write the code of the 3 functions that will return a number which represent the amount of the given color present in the pixel. You can also change the size of the image.

Here is the html file where all you need is in there: https://pastebin.com/LhxUSFuX

Pic related:
red: return (i + j) & j;
green: return (255 + i - j) & i;
blue: return (i + j) & (255 + i - j);

Show me your best

>> No.9588892
File: 345 KB, 600x600, rainbow.png [View same] [iqdb] [saucenao] [google]
9588892

Another example:
Red:
return Math.cos(i * 28 / j) * 255;

Green:
return Math.cos(i * 28 / j - 14) * 255;

Blue:
return Math.cos(i * 28 / j - 28) * 255;

>> No.9588904
File: 2 KB, 256x256, simple.png [View same] [iqdb] [saucenao] [google]
9588904

A really simple one:
Red:
return i;

Green:
return j;

Blue:
return 255;

>> No.9588922
File: 930 KB, 1200x1200, fractal.png [View same] [iqdb] [saucenao] [google]
9588922

Fractal !

getRed: function(i, j) {
var a=0,b=0,d,n=0;
for(;a*a+(d=b*b)<4&&n++<8192;b=2*a*b+j/5e4+.06,a=a*a-d+i/5e4+.34);
return n/4;
},

getGreen: function(i, j) {
return 2 * this.getRed(i ,j);
},

getBlue: function(i, j) {
return 4 * this.getRed(i ,j);
}

>> No.9588951
File: 156 KB, 256x256, random.png [View same] [iqdb] [saucenao] [google]
9588951

Red:
return i * j
Green:
return Math.sin(i * j) * 255;
Blue:
return Math.cos(i * j) * 255;

>> No.9589025
File: 74 KB, 256x256, pixel.png [View same] [iqdb] [saucenao] [google]
9589025

red: return i * i * j;
green: return i * i * j;
blue: return i * i * j * j;

>> No.9589032

I dont get it. Do you want someone to do your homework for you...?

>> No.9589036

>>9589032
Just want to see the /sci/ creativity

>> No.9589123
File: 49 KB, 1024x1024, colorful.png [View same] [iqdb] [saucenao] [google]
9589123

Red: return (i+j)/3;
Green: return (i+2*j)/3;
Blue: return (2*i+j)/3;

>> No.9589170

>>9588874
So, fragment shaders? Why not just make it in shadertoy?
For example: shadertoy_com/view/4sVcR1

>> No.9589207
File: 12 KB, 256x256, download.png [View same] [iqdb] [saucenao] [google]
9589207

>>9588874

>> No.9589260
File: 336 KB, 1024x1024, rows.png [View same] [iqdb] [saucenao] [google]
9589260

Math.sqrt(i*j);
Math.log(i*j);
Math.sqrt(i*j)*4;

>> No.9589319
File: 75 KB, 645x729, d27[1].png [View same] [iqdb] [saucenao] [google]
9589319

>>9588874
I don't understand what you're asking

>> No.9589469
File: 1.25 MB, 701x701, image.png [View same] [iqdb] [saucenao] [google]
9589469

(j - i) * j;
(j+i);

var a;
for(i = 0; i < 255; i++){
a = (i * Math.random()) + j;
}
return a;

>> No.9589885
File: 62 KB, 1024x1024, dots.png [View same] [iqdb] [saucenao] [google]
9589885

sin, cos, and lots of modulus

>> No.9589921

>>9589885
show your work bitchboi

>> No.9590834

>>9589319
looks like pixel shaders

>> No.9591173

where am i supposed to enter this type of data, what even mathematics is this using

>> No.9591287

>>9591173
get the html file on the pastebin link from the OP, then write the content of the three functions in a way that makes a cool picture

>> No.9592595

>>9591287
>get the html file on the pastebin link from the OP
And do what with it, make a website?

>> No.9592742
File: 411 KB, 1024x1024, download (1).png [View same] [iqdb] [saucenao] [google]
9592742

>>9592595
run it in any browser

>> No.9593075

>>9592595
>make a website
kek

>> No.9593077
File: 36 KB, 1024x1024, circle.png [View same] [iqdb] [saucenao] [google]
9593077

return (Math.pow(i - this.size / 2, 2) + Math.pow(j - this.size / 2, 2) - Math.pow(20, 2));

return (Math.pow(i - this.size / 2, 2) + Math.pow(j - this.size / 2, 2) - Math.pow(10, 2));

return (Math.pow(i - this.size / 2, 2) + Math.pow(j - this.size / 2, 2) - Math.pow(50, 2));

>> No.9593948

bump

>> No.9595202
File: 753 KB, 1024x1024, circ.png [View same] [iqdb] [saucenao] [google]
9595202

return (Math.pow(i - this.size / 2, 2) + Math.pow(j - this.size / 2, 2) - Math.pow(20, 2)) / 100;

return (Math.pow(i - this.size / 2, 2) + Math.pow(j - this.size / 2, 2) - Math.pow(40, 2)) / 100;

return (Math.pow(Math.sin(i) * i - this.size / 2, 2) + Math.pow(j - this.size / 2, 2) - Math.pow(60, 2)) / 100;

>> No.9595227
File: 40 KB, 512x512, download.png [View same] [iqdb] [saucenao] [google]
9595227

var def = {
versace: 10000.0,
size: 512,
fuck: function(i, j) {
return Math.sin((i * j) / this.versace) * 255;
},
getRed: function(i, j) {
return Math.max(this.fuck(i, i), this.fuck(j, j));
},

getGreen: function(i, j) {
return Math.max(this.fuck(i, i/3.0), this.fuck(j, j/3.0));
},

getBlue: function(i, j) {
return Math.max(this.fuck(i/2.0, i), this.fuck(j/2.0, j));
},
}

>> No.9595229

go back to /g/

>> No.9595270
File: 56 KB, 512x512, download.png [View same] [iqdb] [saucenao] [google]
9595270

var def = {
size: 512,
getRed: function(i, j) {
return (j + i) * ((j + i) % 3) * 255/ 1024 * 2;
},

getGreen: function(i, j) {
return 2.0 * this.getRed(i, j);
},

getBlue: function(i, j) {
return 4.0 * this.getRed(i, j);
},
}

>> No.9595284
File: 300 KB, 1000x1000, circles.png [View same] [iqdb] [saucenao] [google]
9595284

red:
return (Math.abs(Math.pow(i % 178 - 55, 2) + Math.pow(j % 178 - 55, 2) - Math.pow(50, 2)) < Math.pow(24, 2)) ? 255 : ((this.size - i - j) / this.size * 200 | (i - j) / this.size * 200) + ((this.size - i - this.size + j) / this.size * 200 | (i - this.size + j) / this.size * 200);

green:
return (Math.abs(Math.pow(i % 178 - 55, 4) + Math.pow(j % 178 - 55, 4) - Math.pow(25, 4)) < Math.pow(20, 4)) ? 255 : ((this.size - i - this.size + j) / this.size * 200 | (this.size - i - j) / this.size * 200)

blue:
return (Math.abs(Math.pow(i % 178 - 144, 2) + Math.pow(j % 178 - 144, 2) - Math.pow(30, 2)) < Math.pow(15, 2)) ? 255 : ((i - this.size + j) / this.size * 200 | (i - j) / this.size * 200);

>> No.9595286

>>9595284
Funky

>> No.9595597
File: 462 KB, 511x511, result.png [View same] [iqdb] [saucenao] [google]
9595597

need to try some bitwise functions now

>> No.9595605
File: 910 KB, 1024x1024, alphamask (59).png [View same] [iqdb] [saucenao] [google]
9595605

I some alphamasks ages ago

>> No.9595639
File: 46 KB, 512x512, download.png [View same] [iqdb] [saucenao] [google]
9595639

>> No.9595647
File: 246 KB, 1024x1024, download (1).png [View same] [iqdb] [saucenao] [google]
9595647

>> No.9595661
File: 137 KB, 1024x1024, download (2).png [View same] [iqdb] [saucenao] [google]
9595661

>> No.9596299
File: 3.60 MB, 1592x1578, Screen Shot 2018-03-16 at 2.52.19 PM.png [View same] [iqdb] [saucenao] [google]
9596299

This is a good thread.
Thanks, OP

Tried to see what would happen if I just threw functions at the wall... Pretty pleased with the results.