-
Notifications
You must be signed in to change notification settings - Fork 0
Examples with "fluidJS"
Yuji Sode edited this page Jun 12, 2017
·
4 revisions
1. Example using "canvasFrm.html", "txtCell.js" and "imgMap.js"
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.png.
This image used for limiting area where is relatively lower than surroundings.
//fluidJS_script20170604.js
//based on "script20170522.js"
//[2017-06-04]
//using "canvasFrm.html", "txtCell.js" and "imgMap.js"
_setImg('sample1','./triangle.png');
var y1=imgMap('sample1'),x1,mpReplace;
-
y1.cvs2Map('1000');
//'1000'=1*R+0*G+0*B+0*a
x1=y1();
-
(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.png.
This is screen shot of 10-step result.
Randomly preset simulated fluid flows from where is rich in red color to surroundings.
//fluidJS_script20170606.js
//based on "script20170604.js"
//[2017-06-06]
//using "canvasFrm.html", "txtCell.js", "imgMap.js" and "nXmGen.js"
_setImg('sample1','./apple-red-fruit-ripe-144245.jpeg');
-
//scanning data
var y1=imgMap('sample1'),x1,mp;
y1.cvs2Map('1000');
//'1000'=1*R+0*G+0*B+0*a
x1=y1(),mp=nXmGen(640,435,3).join('@');
-
(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