Skip to content

Examples with "fluidJS"

Yuji Sode edited this page Jun 12, 2017 · 4 revisions

Examples with "fluidJS"

fluidjs_script20170604_100x100
fluidJS_script20170604_100x100.png.
This is result of 10-step result in 100 x 100 px canvas tag.
Simulated fluid flows into relatively low area: triangle and outside of canvas tag.
triangle
triangle.png.
This image used for limiting area where is relatively lower than surroundings.

Script

//fluidJS_script20170604.js
//based on "script20170522.js"
//[2017-06-04]
//using "canvasFrm.html", "txtCell.js" and "imgMap.js"
  1. _setImg('sample1','./triangle.png');
  2. var y1=imgMap('sample1'),x1,mpReplace;
  3. y1.cvs2Map('1000');
    //'1000'=1*R+0*G+0*B+0*a
  4. x1=y1();
  5. (function(n){
     n=/^[0-9]+$/.test(n)?n:10;
     var slf=window,x,y,logX,i=0,tF;
     tF=function(){
         var tId;
         if(i<n){
             x.run();
             logX=x();
             tId=slf.setTimeout(function(){
                 y.map2Cvs(logX.map1);
                 i+=1;
                 tId=slf.setTimeout(tF,1000);
             },800);
         }
     };
     mpReplace=x1.outputMap.replace(/9/g,'1');
     mpReplace=mpReplace.replace(/0/g,8);
     x=txtCell('./fluidJS/fluidJS.js','Fluid simulation','',mpReplace);
     y=imgMap('sample2');
     logX=x();
     y.map2Cvs(logX.map0);
     if(n>0){tF();}
    }(10));
    

This example is derived from https://github.com/YujiSODE/fluidJS/issues/1

2. Screen shot of result with "canvasFrm.html", "txtCell.js", "imgMap.js" and "nXmGen.js"

fluidjs_script20170606ss
fluidJS_script20170606SS.png.
This is screen shot of 10-step result.
Randomly preset simulated fluid flows from where is rich in red color to surroundings.

Script

//fluidJS_script20170606.js
//based on "script20170604.js"
//[2017-06-06]
//using "canvasFrm.html", "txtCell.js", "imgMap.js" and "nXmGen.js"
  1. _setImg('sample1','./apple-red-fruit-ripe-144245.jpeg');
  2. //scanning data
    var y1=imgMap('sample1'),x1,mp;
    y1.cvs2Map('1000');
    //'1000'=1*R+0*G+0*B+0*a
  3. x1=y1(),mp=nXmGen(640,435,3).join('@');
  4. (function(n){
        n=/^[0-9]+$/.test(n)?n:10;
        var slf=window,x,y,logX,i=0,tF;
        tF=function(){
            var tId;
            if(i<n){
                x.run();
                logX=x();
                tId=slf.setTimeout(function(){
                    y.map2Cvs(logX.map1);
                    i+=1;
                    tId=slf.setTimeout(tF,1000);
                },800);
            }
        };
        x=txtCell('./fluidJS/fluidJS.js','Fluid simulation',mp,x1.outputMap);
        y=imgMap('sample2');
        logX=x();
        y.map2Cvs(logX.map0);
        if(n>0){tF();}
    }(10));
    

This example is derived from https://github.com/YujiSODE/fluidJS/issues/1