Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var width = 1920;
- var height = 1080;
- var t = 5;
- var colours = [ [],[],[],[],[],[] ];//hue1, hue2, sat1,sat2, value1, value2
- for(n=0;n<41;n++){
- colours[0][n] = 1+Math.random();
- colours[1][n] = colours[0][n]+0.5-Math.random();
- colours[2][n] = 0.5+0.5*Math.random();
- colours[3][n] = 0.5+0.5*Math.random();
- colours[4][n] = 0.75+0.25*Math.random();
- colours[5][n] = 0.75+0.25*Math.random();
- };
- colours[4][0] = 0.2*Math.random();
- colours[5][0] = 0.2*Math.random();
- var pixels0 = [];
- for(ax=0;ax<width;ax++){
- pixels0[ax] = [];
- for(ay=0;ay<height;ay++){
- pixels0[ax][ay] = pickcolour(ax,ay,0);
- };
- };
- for(bx=0;bx<8;bx++){
- for(by=0;by<5;by++){
- for(ax=Math.max(0,(bx-1)*width/8);ax<Math.min(width,(bx+2)*width/8);ax++){
- for(ay=by*height/5;ay<(by+1)*height/5;ay++){
- if( isshape(6-by,(2*bx+1)*width*19/320+(4-by)*width/80,(2*by+1)*height/10,height/12,2+(bx+1)*2+(4-by)*(5-by),0,ax,ay) ){//isshape(n,x,y,r,p,theta,ax,ay) axis, center x, center y, radius, power, rotation, actual x, actual y
- pixels0[ax][ay] = pickcolour(ax,ay,1+5*bx+by);
- };
- };
- };
- };
- };
- function pickcolour(ax,ay,n){
- var w = (ax/2+ay)/(width/2+height);
- return(rgbtohex(hsvtorgb([], (w*colours[0][n]+(1-w)*colours[1][n])%1, w*colours[2][n]+(1-w)*colours[3][n], w*colours[4][n]+(1-w)*colours[5][n] )));
- };
- draw(t,pixels0);
- function isshape(n,x,y,r,p,theta,ax,ay){//axis, center x, center y, radius, power, rotation, actual x, actual y
- var sum = 0;
- for(nn=0;nn<n;nn++){
- sum+= Math.pow(Math.sin(theta+Math.PI*nn/n)*(x-ax)+Math.sin(theta+Math.PI*(nn/n+1/2))*(y-ay),p)
- };
- if(sum<Math.pow(r,p)){
- return(true);
- }else{
- return(false);
- };
- };
- function blankpixelmap(bd){//bd is value for every pixel
- var ba = [];
- for(bb=0;bb<width;bb++){
- ba[bb] = [];
- for(bc=0;bc<height;bc++){
- ba[bb][bc] = bd;
- };
- };
- return(ba);
- };
- function hsvtorgb(peaks,h,s,v){
- if(peaks.length<2){
- peaks = [ [0,1,0,0],[1/6,1,1,0],[2/6,0,1,0],[3/6,0,1,1],[4/6,0,0,1],[5/6,1,0,1] ];
- };
- if(h<peaks[0][0]){
- var h2 = (h+1-peaks[peaks.length-1][0])/(peaks[0][0]+1-peaks[peaks.length-1][0]);
- return([ v*(1-s)+v*s*(peaks[peaks.length-1][1]+h2*(peaks[0][1]-peaks[peaks.length-1][1])) , v*(1-s)+v*s*(peaks[peaks.length-1][2]+h2*(peaks[0][2]-peaks[peaks.length-1][2])) , v*(1-s)+v*s*(peaks[peaks.length-1][3]+h2*(peaks[0][3]-peaks[peaks.length-1][3])) ]);
- };
- for(ba=1;ba<peaks.length;ba++){
- if(h<peaks[ba][0]){
- var h2 = (h-peaks[ba-1][0])/(peaks[ba][0]-peaks[ba-1][0]);
- return([ v*(1-s)+v*s*(peaks[ba-1][1]+h2*(peaks[ba][1]-peaks[ba-1][1])) , v*(1-s)+v*s*(peaks[ba-1][2]+h2*(peaks[ba][2]-peaks[ba-1][2])) , v*(1-s)+v*s*(peaks[ba-1][3]+h2*(peaks[ba][3]-peaks[ba-1][3])) ]);
- };
- };
- var h2 = (h-peaks[peaks.length-1][0])/(peaks[0][0]+1-peaks[peaks.length-1][0]);
- return([ v*(1-s)+v*s*(peaks[peaks.length-1][1]+h2*(peaks[0][1]-peaks[peaks.length-1][1])) , v*(1-s)+v*s*(peaks[peaks.length-1][2]+h2*(peaks[0][2]-peaks[peaks.length-1][2])) , v*(1-s)+v*s*(peaks[peaks.length-1][3]+h2*(peaks[0][3]-peaks[peaks.length-1][3])) ]);
- };
- function rgbtohex(rgb){//rgb in array
- var hext = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","f"];
- var aa="";
- aa+=hext[ Math.floor( rgb[2]*255.99/16 ) ];
- aa+=hext[ Math.floor( (rgb[2]*255.99)%16 ) ];
- aa+=hext[ Math.floor( rgb[1]*255.99/16 ) ];
- aa+=hext[ Math.floor( (rgb[1]*255.99)%16 ) ];
- aa+=hext[ Math.floor( rgb[0]*255.99/16 ) ];
- aa+=hext[ Math.floor( (rgb[0]*255.99)%16 ) ];
- return(aa);
- };
- function draw(frame,hexmap){
- /*640x360 header*///var mytext = "424D368C0A0000000000360000002800000080020000680100000100180000000000008C0A0000000000000000000000000000000000";
- /*1920x1080 header*/ var mytext = "424D36EC5E000000000036000000280000008007000038040000010018000000000000EC5E0000000000000000000000000000000000";
- /*3840x2160 header*/// var mytext = "424D36B07B01000000003600000028000000000F000070080000010018000000000000B07B0100000000000000000000000000000000";
- for(ay=0;ay<hexmap[0].length;ay++){
- for(ax=0;ax<hexmap.length;ax++){
- mytext+=hexmap[ax][ay];
- };
- };
- var fs = require('fs');
- var buf = new Buffer.from(mytext, 'hex');
- var pad = ["000","00","0",""];
- fs.writeFile('img-'+pad[(""+frame).length-1]+frame+'.bmp', buf, (err) => { if (err) throw err; });
- };
Advertisement
Add Comment
Please, Sign In to add comment