Open YujiSODE opened 2 years ago
imaginaryLandform_hex.js (Sode, 2018): the MIT License; https://gist.github.com/YujiSODE/e67e561b2e14dd84ff93efb672001bdb
//3CC_sample01_v02.js
//random sample
//
var sampleCode=()=>{
let ctx=document.getElementById('threeCellContourCvs').getContext('2d'),
W=ctx.canvas.width,H=ctx.canvas.height,
R0=Math.sqrt(W*W+H*H),
R=0.05*R0,
X=0.0,Y=0.0,
i=0,N=100;
//
const PI2=2.0*Math.PI;
//
ctx.fillStyle='#00ff';
ctx.clearRect(0,0,W,H);
ctx.beginPath();
//
while(i<N){
X=W*Math.random();
Y=H*Math.random();
//
ctx.moveTo(X,Y);
ctx.arc(X,Y,R*Math.random(),0.0,PI2,false);
ctx.fill();
//
i+=1;
}
ctx=W=H=R0=R=X=Y=i=N=null;
};
vertices ≤ 2*N+1
when N = 36
sample: https://github.com/YujiSODE/threeCellContour/issues/5#issuecomment-1002969650
vertices ≤ 2*N+1
when N = 15
sample: https://github.com/YujiSODE/threeCellContour/issues/5#issuecomment-1002969650
vertices ≤ 2*N+1
when N = 2
sample: https://github.com/YujiSODE/threeCellContour/issues/5#issuecomment-1002969650
vertices ≤ 2*N+1
when N = 1
sample: https://github.com/YujiSODE/threeCellContour/issues/5#issuecomment-1002969650
//3CC_sample01_v03.js
//random sample
//
//function that draws sample data on canvas element
var SAMPLE=()=>{};
//
//n is sample set size
var setSample=(n)=>{
let arr=[],i=0,N=Math.floor(n);
N=N<1?1:N;
//
while(i<N){
arr.push(Math.random(),Math.random(),Math.random());
//
i+=1;
}
//
return ()=>{
let ctx=document.getElementById('threeCellContourCvs').getContext('2d'),
W=ctx.canvas.width,H=ctx.canvas.height,
R0=Math.sqrt(W*W+H*H),
R=0.025*R0,
X=0.0,Y=0.0,
i=0,n=arr.length;
//
const PI2=2.0*Math.PI;
//
ctx.fillStyle='#00ff';
ctx.clearRect(0,0,W,H);
ctx.beginPath();
//
while(i<n){
X=W*arr[i];
Y=H*arr[i+1];
//
ctx.moveTo(X,Y);
ctx.arc(X,Y,R*arr[i+2],0.0,PI2,false);
ctx.fill();
//
i+=3;
}
ctx=W=H=R0=R=X=Y=i=n=null;
};
};
//
SAMPLE=setSample(100);
SAMPLE();
//
//=== to reset data set ===
//SAMPLE=setSample(sampleSize);
//=========================
vertices ≤ 2*N+1
sample: https://github.com/YujiSODE/threeCellContour/issues/5#issuecomment-1002969650
sample results