|
|
|
var canvas=document.getElementById("canvas"); |
|
var draw=canvas.getContext('2d'); |
|
{ |
|
function saveOct(oct)//saves all the data in an octave tab |
|
{ |
|
octaveData[oct]=[]; |
|
octaveData[oct].push(document.getElementById("pointSpacing").value); |
|
octaveData[oct].push(document.getElementById("poissonTries").value); |
|
octaveData[oct].push(document.getElementById("functList").value); |
|
octaveData[oct].push(document.getElementById("simplexSum").checked); |
|
octaveData[oct].push(document.getElementById("effRadSum").value); |
|
octaveData[oct].push(document.getElementById("functSum").value); |
|
octaveData[oct].push(document.getElementById("simplexCell").checked); |
|
octaveData[oct].push(document.getElementById("effRadCell").value); |
|
octaveData[oct].push(document.getElementById("functCell").value); |
|
} |
|
function defaultOct(oct)//Fills an octave tab with default data |
|
{ |
|
octaveData[oct]=[]; |
|
octaveData[oct].push(64/Math.pow(2,oct));//0 |
|
octaveData[oct].push(64+oct);//1 |
|
octaveData[oct].push("[x,y]");//2 |
|
octaveData[oct].push(false);//3 |
|
octaveData[oct].push(128/Math.pow(2,oct));//4 |
|
octaveData[oct].push("dot/Math.exp(11*Math.pow(dist,4))");//5 |
|
octaveData[oct].push(false);//6 |
|
octaveData[oct].push(128/Math.pow(2,oct));//7 |
|
octaveData[oct].push("dist");//8 |
|
//console.log(octaveData[oct]); |
|
} |
|
function loadOct(oct)//Loads an octave tab |
|
{ |
|
document.getElementById("pointSpacing").value=octaveData[oct][0]; |
|
document.getElementById("poissonTries").value=octaveData[oct][1]; |
|
document.getElementById("functList").value=octaveData[oct][2]; |
|
document.getElementById("simplexSum").checked=octaveData[oct][3]; |
|
document.getElementById("effRadSum").value=octaveData[oct][4]; |
|
document.getElementById("functSum").value=octaveData[oct][5]; |
|
document.getElementById("simplexCell").checked=octaveData[oct][6]; |
|
document.getElementById("effRadCell").value=octaveData[oct][7]; |
|
document.getElementById("functCell").value=octaveData[oct][8]; |
|
} |
|
function openOct(oct)//Saves current octave and loads another |
|
{ |
|
//console.log("Attempted to open"); |
|
saveOct(octave); |
|
octave=oct; |
|
loadOct(oct); |
|
document.getElementById("octHeader").innerHTML = `Octave settings: ${oct}`; |
|
} |
|
function openOct2(oct) |
|
{ |
|
octave=oct; |
|
loadOct(oct); |
|
document.getElementById("octHeader").innerHTML = `Octave settings:${oct}`; |
|
} |
|
var map=[]//Height,red,green,blue |
|
function combine() |
|
{ |
|
//console.log("combine attempted") |
|
var w=gridSum[0].length; |
|
var h=gridSum[0][0].length; |
|
canvas.width=w*2; |
|
canvas.height=h*2; |
|
map=gridBlank(w,h,[0,0,0,0]); |
|
var equ=new Function('x','y','w','h','var height=0;var red=0; var blue=0;var green=0;'+document.getElementById('combineGen').value+'return [height,red,blue,green]'); |
|
//console.log("checkpoint 4"); |
|
for (x=0;x<w;x++) |
|
{ |
|
for (y=0;y<h;y++) |
|
{ |
|
map[x][y]=equ(x,y,w,h); |
|
} |
|
} |
|
//console.log("Combine registered") |
|
renderBegin(); |
|
} |
|
} |
|
//Noise Functions |
|
{ |
|
function gridBlank(w,h,fill) |
|
{ |
|
var array=[]//Declares array |
|
for(x=0;x<w;x++)//Cycles columns |
|
{ |
|
array.push([]);//Adds a column |
|
for(y=0;y<h;y++)//Cycles positions of columsn |
|
{ |
|
array[x].push(fill)//Makes an entry |
|
} |
|
} |
|
return array; |
|
} |
|
function gridRescale(grid) |
|
{ |
|
var max=0; |
|
var min=Math.pow(2,16); |
|
var w=grid.length; |
|
var h=grid[0].length; |
|
for(x=0;x<w;x++)//Cycles columns |
|
{ |
|
for(y=0;y<h;y++)//Cycles positions of columsn |
|
{ |
|
max=Math.max(grid[x][y],max); |
|
min=Math.min(grid[x][y],min); |
|
} |
|
} |
|
for(x=0;x<w;x++)//Cycles columns |
|
{ |
|
for(y=0;y<h;y++)//Cycles positions of columsn |
|
{ |
|
grid[x][y]=(grid[x][y]-min)/(max-min); |
|
} |
|
} |
|
} |
|
var gridSum=[]; |
|
var gridWor=[]; |
|
var gridVor=[]; |
|
var vorList=[]; |
|
var poisson=gridBlank(256,256,0); |
|
for (ind=0;ind<10;ind++) |
|
{ |
|
vorList.push([]); |
|
gridSum.push(gridBlank(256,256,0)); |
|
gridWor.push([gridBlank(256,256,0),gridBlank(256,256,0),gridBlank(256,256,0),]); |
|
gridVor.push([gridBlank(256,256,0),gridBlank(256,256,0),gridBlank(256,256,0),]); |
|
} |
|
function circleNoise(oct,x,y,inSimplex,point)//Places a cirlce of values in the noisemap |
|
{ |
|
var pointSpacing=octaveData[oct][0]; |
|
var poissonTries=octaveData[oct][1]; |
|
var functList=new Function('x','y','point','vectx','vecty',"return ("+ octaveData[oct][2]+")"); |
|
var sumSimplex=octaveData[oct][3]; |
|
var effRadSum=Math.floor(octaveData[oct][4]); |
|
var functSum=new Function('dist','dot','x','y','point','vectx','vecty',"return ("+ octaveData[oct][5]+")"); |
|
var cellSimplex=octaveData[oct][6]; |
|
var effRadCell=Math.floor(octaveData[oct][7]); |
|
var functCell=new Function('dist','dot','x','y','point','vectx','vecty',"return ("+ octaveData[oct][8]+")"); |
|
|
|
//console.log(functSum); console.log(functCell); |
|
var width=poisson.length; |
|
var height=poisson[0].length; |
|
|
|
var radius=Math.floor(Math.max(effRadCell,effRadSum,pointSpacing)); |
|
var theta=Math.random()*2*Math.PI;//Angle for gradient vector |
|
var vectx=Math.cos(theta);//X compnent of vector |
|
var vecty=Math.sin(theta);//Y component of vector |
|
if (cellSimplex==inSimplex) |
|
{vorList[oct].push(functList(x,y,point,vectx,vecty))}; |
|
var width2; |
|
if (inSimplex==true){width2=pointSpacing*Math.ceil(width/(pointSpacing*Math.sqrt(3)/2))} |
|
else {width2=width} |
|
for(xx=-radius;xx<radius;xx++) |
|
{ |
|
var radius2=Math.floor(Math.sqrt(Math.abs(radius*radius-xx*xx))); |
|
for(yy=-radius2;yy<radius2;yy++) |
|
{ |
|
var arrx=x+xx-width2*Math.floor((x+xx)/width2);//Coordinates of pixel in image |
|
var arry=y+yy-height*Math.floor((y+yy)/height); |
|
if (arrx<width) |
|
{ |
|
if ((Math.sqrt(xx*xx+yy*yy)<pointSpacing)&&(inSimplex==false)){poisson[arrx][arry]=1} |
|
if ((Math.sqrt(xx*xx+yy*yy)<effRadSum)&&(sumSimplex==inSimplex))//Adds value to summation noisemap |
|
{ |
|
var eux=xx/effRadSum; |
|
var euy=yy/effRadSum; |
|
var dot=vectx*eux+vecty*euy; |
|
var dist=Math.sqrt(eux*eux+euy*euy); |
|
gridSum[oct][arrx][arry]+=functSum(dist,dot,eux,euy,point,vectx,vecty); |
|
} |
|
if ((Math.sqrt(xx*xx+yy*yy)<effRadCell)&&(cellSimplex==inSimplex)) |
|
{ |
|
var eux=xx/effRadCell; |
|
var euy=yy/effRadCell; |
|
var dot=vectx*eux+vecty*euy; |
|
var dist=Math.sqrt(eux*eux+euy*euy); |
|
var val=functCell(dist,dot,eux,euy,point,vectx,vecty); |
|
if (val<=gridWor[oct][0][arrx][arry]) |
|
{ |
|
gridWor[oct][2][arrx][arry]=gridWor[oct][1][arrx][arry]; |
|
gridWor[oct][1][arrx][arry]=gridWor[oct][0][arrx][arry]; |
|
gridWor[oct][0][arrx][arry]=val; |
|
gridVor[oct][2][arrx][arry]=gridVor[oct][1][arrx][arry]; |
|
gridVor[oct][1][arrx][arry]=gridVor[oct][0][arrx][arry]; |
|
gridVor[oct][0][arrx][arry]=point; |
|
} |
|
else if (val<=gridWor[oct][1][arrx][arry]) |
|
{ |
|
gridWor[oct][2][arrx][arry]=gridWor[oct][1][arrx][arry]; |
|
gridWor[oct][1][arrx][arry]=val; |
|
gridVor[oct][2][arrx][arry]=gridVor[oct][1][arrx][arry]; |
|
gridVor[oct][1][arrx][arry]=point; |
|
} |
|
else if (val<=gridWor[oct][2][arrx][arry]) |
|
{ |
|
gridWor[oct][2][arrx][arry]=val; |
|
gridVor[oct][2][arrx][arry]=point; |
|
} |
|
} |
|
}//SImplex bracket |
|
} |
|
} |
|
//console.log("checkpoint 3") |
|
} |
|
function noiseHub(w,h,oct) |
|
{ |
|
//console.log("attempting to generate one octave") |
|
var pointSpacing=octaveData[oct][0]; |
|
var poissonTries=octaveData[oct][1]; |
|
//var functList=octaveData[oct][2]; |
|
var sumSimplex=octaveData[oct][3]; |
|
//var effRadSum=Math.floor(octaveData[oct][4]); |
|
//var functSum=new Function('dist','dot','relX','relY',octaveData[oct][5]); |
|
var cellSimplex=octaveData[oct][6]; |
|
//var effRadCell=Math.floor(octaveData[oct][7]); |
|
//var functCell=new Function('dist','dot','relX','relY',octaveData[oct][8]); |
|
poisson=gridBlank(w,h,0);//Poisson areas |
|
var done=false; |
|
var point=0;//ID of point. Will be used for Voronoi. |
|
if ((sumSimplex==false)||(cellSimplex==false)) |
|
{ |
|
do |
|
{//Finds coord in grid that are not within poisson distance of another poi |
|
var x=Math.floor(Math.random()*w); |
|
var y=Math.floor(Math.random()*h); |
|
var tries=0; |
|
do{ x=Math.floor(Math.random()*w);y=Math.floor(Math.random()*h);tries++} |
|
while ((poisson[x][y]==1)&&(tries<poissonTries))//Only does until grid likely full |
|
if (tries>=poissonTries){done=true;}//If likely full, this will be last loop |
|
//Places circle into noisemap |
|
//console.log("checkpoint 2") |
|
circleNoise(oct,x,y,false,point) |
|
point+=1; |
|
} |
|
while (done==false) |
|
} |
|
point=0; |
|
if ((sumSimplex==true)||(cellSimplex==true)) |
|
{ |
|
var hSimp=Math.ceil(h/pointSpacing); |
|
var wSimp=1+Math.ceil(w/(pointSpacing*Math.sqrt(3)/2)); |
|
for(x=0;x<wSimp;x++) |
|
{ |
|
for(y=0;y<hSimp;y++) |
|
{ |
|
var xx=Math.floor(x*pointSpacing*Math.sqrt(3)/2); |
|
var yy=Math.floor((y+(x%2)/2)*pointSpacing); |
|
circleNoise(oct,xx,yy,true,point); |
|
point+=1; |
|
} |
|
} |
|
} |
|
} |
|
function genOctaves() |
|
{ |
|
//console.log("attempting to generate octaves") |
|
saveOct(octave); |
|
var width=document.getElementById("imgWidth").value; |
|
var height=document.getElementById("imgHeight").value; |
|
vorList=[]; |
|
gridSum=[];//Summation values |
|
gridWor=[];//Cellular min |
|
gridVor=[]; |
|
for(octInd=0;octInd<10;octInd++) |
|
{ |
|
var fillval=Math.pow(2,16); |
|
vorList.push([]); |
|
gridSum.push(gridBlank(width,height,0));//Summation values |
|
gridWor.push([gridBlank(width,height,fillval),gridBlank(width,height,fillval),gridBlank(width,height,fillval)]);//Cellular min |
|
gridVor.push([gridBlank(width,height,0),gridBlank(width,height,0),gridBlank(width,height,0)]);//Cellular regions |
|
if (document.getElementById(`useOct${octInd}`).checked==true) |
|
{ |
|
//console.log("checkpoint 1"); |
|
noiseHub(width,height,octInd); |
|
gridRescale(gridSum[octInd]); |
|
} |
|
} |
|
//console.log("Octavegen registered"); |
|
combine(); |
|
adjust(); |
|
} |
|
//For retrieving noise functions |
|
function nSum(oct,x,y) |
|
{ |
|
var grid=gridSum[oct] |
|
var w=grid.length; |
|
var h=grid[0].length; |
|
var nx=Math.floor(x-w*Math.floor(x/w)); |
|
var ny=Math.floor(y-h*Math.floor(y/h)); |
|
return grid[nx][ny]; |
|
} |
|
function nWor(oct,type,x,y) |
|
{ |
|
var grid=gridWor[oct][type] |
|
var w=grid.length; |
|
var h=grid[0].length; |
|
var nx=Math.floor(x-w*Math.floor(x/w)); |
|
var ny=Math.floor(y-h*Math.floor(y/h)); |
|
return grid[nx][ny]; |
|
} |
|
function nVor(oct,type,x,y) |
|
{ |
|
var grid=gridVor[oct][type] |
|
var w=grid.length; |
|
var h=grid[0].length; |
|
var nx=Math.floor(x-w*Math.floor(x/w)); |
|
var ny=Math.floor(y-h*Math.floor(y/h)); |
|
var index=grid[nx][ny]; |
|
return vorList[oct][index] |
|
} |
|
} |
|
//Draw Functions |
|
{ |
|
|
|
function render2d() |
|
{ |
|
var w=map.length; |
|
var h=map[0].length; |
|
canvas.width=2*w; |
|
canvas.height=2*h; |
|
var useGray=document.getElementById("grayScaleBool").checked; |
|
for (x=0;x<w;x++) |
|
{ |
|
for(y=0;y<h;y++) |
|
{ |
|
var dot=1; |
|
var color="red"; |
|
if (useGray==true) |
|
{ |
|
var shade=Math.min(255,Math.floor(map[x][y][0])); |
|
color=`rgb(${shade},${shade},${shade})`; |
|
} |
|
else |
|
{ |
|
var red=Math.floor(Math.min(255,map[x][y][1])); |
|
var blue=Math.floor(Math.min(255,map[x][y][2])); |
|
var green=Math.floor(Math.min(255,map[x][y][3])); |
|
color=`rgb(${red},${green},${blue})`; |
|
} |
|
draw.fillStyle=color; |
|
draw.fillRect(2*x,2*y,2,2); |
|
} |
|
} |
|
} |
|
function renderBegin() |
|
{ |
|
var useDim=document.getElementById("2.5DBool").checked; |
|
if (useDim==false){render2d()} |
|
else {render3d()} |
|
} |
|
} |
|
function render3d() |
|
{ |
|
var w=map.length; |
|
var h=map[0].length; |
|
var useGray=document.getElementById("grayScaleBool").checked; |
|
var extrusion=document.getElementById("extrusion").value/4; |
|
|
|
canvas.width=2*w; |
|
canvas.height=2*h; |
|
var lightVert=document.getElementById("lightVert").value//AsNumber |
|
var lightHori=document.getElementById("lightHori").value//AsNumber |
|
var lightBright=document.getElementById("lightBright").value//AsNumber |
|
var lightVectX=lightBright*Math.cos(lightHori*Math.PI)*Math.sin(lightVert*Math.PI); |
|
var lightVectY=lightBright*Math.sin(lightHori*Math.PI)*Math.sin(lightVert*Math.PI); |
|
var lightVectZ=lightBright*Math.cos(lightVert*Math.PI); |
|
|
|
//console.log(renderMap[0][0].length) |
|
var shading=Math.pow(document.getElementById("shading").value,2); |
|
for (x=0;x<w;x++) |
|
{ |
|
var drawWrap=[]; |
|
for(y=0;y<h;y++) |
|
{ |
|
//Finds the lighting value |
|
var xLeft=x-1-w*Math.floor((x-1)/w); |
|
var xRight=x+1-w*Math.floor((x+1)/w); |
|
var yUp=y-1-h*Math.floor((y-1)/h); |
|
var yDown=y+1-h*Math.floor((y+1)/h); |
|
var slopeX=4*shading*(map[xRight][y][0]-map[xLeft][y][0])/2;//U(1,0,slope) |
|
var slopeY=4*shading*(map[x][yDown][0]-map[x][yUp][0])/2;//V(0,1,slope) |
|
var mag=Math.sqrt(slopeX*slopeX+slopeY*slopeY+1) |
|
var normX=slopeX/mag; |
|
var normY=slopeY/mag; |
|
var normZ=1/mag; |
|
var dot=(slopeX*lightVectX+slopeY*lightVectY+lightVectZ)/mag;//Dot product for lighting |
|
//Finds the color to draw |
|
var red=0; |
|
var green=0; |
|
var blue=0; |
|
if (useGray==true) |
|
{ |
|
red=Math.floor(Math.min(255,dot*map[x][y][0])); |
|
green=red;blue=red; |
|
} |
|
else |
|
{ |
|
red=Math.floor(Math.min(255,dot*map[x][y][1])); |
|
blue=Math.floor(Math.min(255,dot*map[x][y][2])); |
|
green=Math.floor(Math.min(255,dot*map[x][y][3])); |
|
} |
|
var color=`rgb(${red},${green},${blue})`; |
|
draw.fillStyle=color; |
|
var elevate=Math.max(2*extrusion*map[x][y][0],0); |
|
//Draws the pixel |
|
var newY=2*y-elevate; |
|
draw.fillRect(2*x,newY,2,2+elevate); |
|
if (newY<0){drawWrap.push([(-newY),color])};//Things that need to be drawn from the bottom |
|
} |
|
for(ind=0;ind<drawWrap.length;ind++) |
|
{ |
|
draw.fillStyle=drawWrap[ind][1]; |
|
var elevate=drawWrap[ind][0]; |
|
draw.fillRect(2*x,2*h-elevate,2,2+elevate); |
|
} |
|
} |
|
} |
|
console.log("hello") |
|
//genOctaves() |
|
|
|
function getProjectString() |
|
{ |
|
var width=document.getElementById('imgWidth').value; |
|
var height=document.getElementById('imgHeight').value; |
|
var grayscale=document.getElementById('grayScaleBool').checked; |
|
var dimension=document.getElementById('2.5DBool').checked; |
|
var extrusion=document.getElementById('extrusion').value; |
|
var shading=document.getElementById('shading').value; |
|
var brightness=document.getElementById('lightBright').value; |
|
var vertical=document.getElementById('lightVert').value; |
|
var horizontal=document.getElementById('lightVert').value; |
|
var str1=`setGlobals(${width},${height},${grayscale},${dimension},${extrusion},${shading},${brightness},${vertical},${horizontal});` |
|
for(octInd=0;octInd<10;octInd++) |
|
{ |
|
if (document.getElementById(`useOct${octInd}`).checked) |
|
{ |
|
//str1=str1+`document.getElementById(${octstr}).checked=true;` |
|
str1=str1+`document.getElementById("useOct${octInd}").checked=true;octaveData[${octInd}]=[`; |
|
for (ind=0;ind<9;ind++) |
|
{ |
|
if (ind==2||ind==5||ind==8) |
|
{str1=str1+'"'+octaveData[octInd][ind]+'"';} |
|
else {str1=str1+octaveData[octInd][ind];} |
|
if (ind!=8){str1=str1+','} |
|
} |
|
str1=str1+"];" |
|
//str1=str1+`octaveData[${octInd}]=[${octaveData[octInd]}]`; |
|
} |
|
} |
|
str1=str1+`document.getElementById('combineGen').value="`+document.getElementById("combineGen").value+';"'; |
|
str1=str1.replace(/(\r\n|\n|\r)/gm," "); |
|
return str1; |
|
} |
|
function setGlobals(width,height,grayscale,dimension,extrusion,shading,brightness,vertical,horizontal) |
|
{ |
|
document.getElementById('imgWidth').value=width; |
|
document.getElementById('imgHeight').value=height; |
|
document.getElementById('grayScaleBool').checked=grayscale; |
|
document.getElementById('2.5DBool').checked=dimension; |
|
document.getElementById('extrusion').value=extrusion; |
|
document.getElementById('shading').value=shading; |
|
document.getElementById('lightBright').value=brightness; |
|
document.getElementById('lightVert').value=vertical; |
|
document.getElementById('lightVert').value=horizontal; |
|
} |
|
function executeString(string) |
|
{ |
|
var str1=string.replace(/(\r\n|\n|\r)/gm," "); |
|
var funct=new Function(str1); |
|
funct(); |
|
} |
|
|
|
function cos(n){return Math.cos(n)} |
|
function sin(n){return Math.sin(n)} |
|
function tan(n){return Math.tan(n)} |
|
function acos(n){return Math.acos(n)} |
|
function asin(n){return Math.asin(n)} |
|
function atan(n){return Math.atan(n)} |
|
function atan2(n,m){return Math.atan2(n,m)} |
|
function abs(n){return Math.abs(n)} |
|
function floor(n){return Math.floor(n)} |
|
function ceil(n){return Math.ceil(n)} |
|
function round(n){return Math.round(n)} |
|
function random(){return Math.random()} |
|
function randomRange(n,m){return (n+(m-n)*Math.random())} |
|
function pow(n,m){return Math.pow(n,m)} |
|
function sqrt(n){return Math.sqrt(n)} |
|
function sqr(n){return n*n} |
|
function cube(n){return n*n*n} |
|
function cbrt(n){return Math.pown(n,1/3)} |
|
function exp(n){return Math.exp(n)} |
|
function log(n){return Math.log(n)/Math.log(10)} |
|
function ln(n){return Math.log(n)} |
|
function logBase(n,m){return Math.log(n)/Math.log(m)} |
|
function exp(n){return Math.exp(n)} |
|
function equ(n,m){if (n==m){return 1} else{return 0}} |
|
function more(n,m){if (n>m){return 1} else{return 0}} |
|
function less(n,m){if (n<m){return 1} else{return 0}} |
|
function atleast(n,m){if (n>=m){return 1} else{return 0}} |
|
function atmost(n,m){if (n<=m){return 1} else{return 0}} |
|
|
|
var octave=0; |
|
var octaveData=[]; |
|
for(oct=0;oct<10;oct++){defaultOct(oct);} |
|
loadOct(0); |
|
document.getElementById("combineGen").value="height=128*nSum(0,x,y)*(1+nSum(1,x,y)*(1+nSum(2,x,y)*(1+nSum(3,x,y)*(1+nSum(4,x,y)+(1+nSum(5,x,y))))));var gray=height;red=gray;blue=gray;green=gray;"; |
|
setGlobals(128,128,false,true,0.69,0.28,1.04,0.21,0.21); |
|
//genOctaves(0); |
|
|
|
function cancelOct() |
|
{ |
|
for(oct=0;oct<10;oct++) |
|
{ |
|
document.getElementById(`useOct${oct}`).checked=false; |
|
} |
|
} |
|
|
|
function setSand(){ |
|
cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,1,0.15,1.55,0.35,0.35);document.getElementById("useOct0").checked=true;octaveData[0]=[8,64,"[x,y]",false,16,"dot/Math.exp(11*Math.pow(dist,4))",false,128,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[32,65,"[x,y]",false,64,"dot/Math.exp(11*Math.pow(dist,4))",false,64,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[16,66,"floor(2*sqr(random()))",false,32,"dot/Math.exp(11*Math.pow(dist,4))",false,32,"dist"];document.getElementById('combineGen').value="var nx=x+16*cos(6*nSum(1,x,y));var ny=y+16*sin(6*nSum(1,x,y));var sand=128*(sqr(nWor(1,0,nx,ny)));var grit=1/2+nSum(0,8*x,8*y);var pebble=64*Math.max(0,nVor(2,0,x,y)*(nWor(2,1,x,y)-nWor(2,0,x,y))-1/3);height=pebble+sand;if (pebble==0){red=220*grit; green=200*grit; blue=140*grit;};if (pebble>0){red=140; green=120; blue=90;};;"` |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves();} |
|
|
|
function setGrass(){cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,false,0.07,0.1,1.04,0.25,0.25);document.getElementById("useOct0").checked=true;octaveData[0]=[16,64,"[x,y]",false,128,"dot/Math.exp(11*Math.pow(dist,4))",false,96,"dot*(atmost(x*vecty-y*vectx-(1-dist)/8,0)*atleast(x*vecty-y*vectx+(1-dist)/8,0)+atmost(x*vecty-y*vectx-(1-dist)/64,0)*atleast(x*vecty-y*vectx+(1-dist)/64,0)/4)"];document.getElementById("useOct1").checked=true;octaveData[1]=[8,65,"[x,y]",false,16,"dot/Math.exp(11*Math.pow(dist,4))",false,64,"dist"];document.getElementById('combineGen').value="var grass=128*(1/4-nWor(0,0,x,y)); var grit=nSum(1,4*x,4*y); if (nWor(0,0,x,y)<-1/16){red=grass;green=2*grass;} if (nWor(0,0,x,y)>-1/16){red=grit*140;green=grit*120;blue=grit*90} ;;"` |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves();} |
|
|
|
function setBricks() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0.09,0.17,1.55,0.3,0.3);document.getElementById("useOct0").checked=true;octaveData[0]=[2,64,"[x,y]",false,8,"y/exp(11*dist*dist)",false,32,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[16,65,"[x,y]",false,32,"dot/Math.exp(11*Math.pow(dist,4))",false,64,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[4,66,"[x,y]",false,8,"dot/Math.exp(11*Math.pow(dist,4))",false,32,"dist"];document.getElementById('combineGen').value="var yscale=16; var brick1=(yscale-abs((y%(2*yscale))-yscale)); var xscale=32; var brick2=(xscale-abs(((x+xscale*(floor(y/yscale/2)))%(2*xscale))-xscale)); brick=Math.min(4,brick1,brick2); drip=nSum(0,x,y); height=8*brick*(1+drip/2); var shade=1/2+sqr(nSum(1,x+xscale*(floor(y/yscale/2)),y)); var grit=24*(1+nSum(2,2*x,2*y)); var shade2=6; if (brick==4){shade2=2}; if (height>grit){red=220*shade;green=90*shade;blue=50*shade;}; if (height<=grit){red=shade2*grit;blue=shade2*grit;green=shade2*grit;if(height<32){height=grit-16;}else{height=height-grit/8}};;;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
|
|
function setStones() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0.06,0.51,1.44,0.12,0.12);document.getElementById("useOct0").checked=true;octaveData[0]=[32,64,"[x,y]",false,64,"dot/Math.exp(11*Math.pow(dist,4))",false,64,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[8,65,"[x,y]",false,16,"dot/Math.exp(11*Math.pow(dist,4))",false,24,"dist"];document.getElementById('combineGen').value="var tile=pow(nWor(0,2,x,y)-nWor(0,1,x,y),1/32); height=256*tile*(1+(1+nWor(1,2,x,y))*(nSum(1,x,y))/16); var grit=1+nSum(1,4*x,4*y)*nSum(0,4*x,4*y)-nWor(1,0,x,y); red=100*grit;green=90*sqr(grit);blue=60*sqrt(grit/4);;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
|
|
function setAgate() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,false,0.36,0.01,1.48,0.3,0.3);document.getElementById("useOct0").checked=true;octaveData[0]=[32,64,"[randomRange(0,255),randomRange(0,255),randomRange(0,255),]",false,64,"dot/Math.exp(11*Math.pow(dist,4))",false,64,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[8,65,"[randomRange(0,255),randomRange(0,255),randomRange(0,255),]",false,16,"dot/Math.exp(11*Math.pow(dist,4))",false,24,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[64,66,"[x,y]",false,32,"dot/Math.exp(11*Math.pow(dist,4))",false,128,"dist"];document.getElementById('combineGen').value="var deposit=1-nWor(2,0,x,y)*(1/2+nWor(0,0,x,y)*(1+nWor(1,0,x,y))); var step=128; var color=[nVor(1,0,step*deposit,step*deposit),nVor(1,1,step*deposit,step*deposit),nVor(1,2,step*deposit,step*deposit)]; red=(color[0][0]+color[0][1]+color[0][2])/3; green=(color[1][0]+color[1][1]+color[1][2])/3; blue=(color[2][0]+color[2][1]+color[2][2])/3; height=128*deposit;;;;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
|
|
function setRock() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0,0.28,0.9,0.11,0.11);document.getElementById("useOct0").checked=true;octaveData[0]=[32,64,"[randomRange(0,255),randomRange(0,255),randomRange(0,255),]",false,96,"dot/Math.exp(11*Math.pow(dist,4))",false,96,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[16,65,"[randomRange(0,255),randomRange(0,255),randomRange(0,255),]",false,48,"dot/Math.exp(11*Math.pow(dist,4))",false,48,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[8,66,"[x,y]",false,24,"dot/Math.exp(11*Math.pow(dist,4))",false,28,"dist"];document.getElementById("useOct3").checked=true;octaveData[3]=[4,67,"[x,y]",false,12,"dot/Math.exp(11*Math.pow(dist,4))",false,12,"dist"];document.getElementById("useOct4").checked=true;octaveData[4]=[2,68,"[x,y]",false,6,"dot/Math.exp(11*Math.pow(dist,4))",false,8,"dist"];document.getElementById('combineGen').value="var stone=(1-nWor(0,2,x,y))*(1+(1-nWor(1,2,x,y))*(1+(1-nWor(2,2,x,y))*(1-nWor(3,2,x,y))*(1+(1-nWor(4,2,x,y)/2)/2)/2)/2); var tex=(nSum(0,x,y)+nSum(1,x,y)/2+nSum(2,x,y)/3+nSum(3,x,y)/4+nSum(4,x,y)/5)/3; height=stone*128; red=144*(1+tex);green=144*(1+tex);blue=154*(1+tex);;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
|
|
function setLava() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0.24,0.11,2.73,0.3,0.3);document.getElementById("useOct0").checked=true;octaveData[0]=[32,64,"[randomRange(0,255),randomRange(0,255),randomRange(0,255),]",false,96,"dot/Math.exp(11*Math.pow(dist,4))",false,96,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[16,65,"[randomRange(0,255),randomRange(0,255),randomRange(0,255),]",false,48,"dot/Math.exp(11*Math.pow(dist,4))",false,48,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[8,66,"[x,y]",false,24,"dot/Math.exp(11*Math.pow(dist,4))",false,28,"dist"];document.getElementById("useOct3").checked=true;octaveData[3]=[4,67,"[x,y]",false,12,"dot/Math.exp(11*Math.pow(dist,4))",false,12,"dist"];document.getElementById("useOct4").checked=true;octaveData[4]=[2,68,"[x,y]",false,6,"dot/Math.exp(11*Math.pow(dist,4))",false,8,"dist"];document.getElementById('combineGen').value="var theta=6.28*nSum(0,x,y); var nx=x+16*cos(theta); var ny=y+16*sin(theta); var lava=pow(1-sqrt(abs(nSum(0,nx,ny)*2-1))*sqrt(abs(nSum(1,nx,ny)*2-1))*sqrt(abs(nSum(2,nx,ny)*2-1))*sqrt(abs(nSum(3,nx,ny)*2-1)),24); var blob=(abs(nSum(0,nx,ny)*2-1))*(1+abs(nSum(1,nx,ny)*2-1)*(1+abs(nSum(2,nx,ny)*2-1)*(1+abs(nSum(3,nx,ny)*2-1)*(1+abs(nSum(4,nx,ny)*2-1))))); height=128*(blob-lava/8); red=(lava+1/16)*128;green=(lava+1/8)*32;;;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
|
|
function setHive() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0,0.04,4,0.45,0.45);document.getElementById("useOct0").checked=true;octaveData[0]=[32,64,"[randomRange(0,255),randomRange(0,255),randomRange(0,255),]",false,64,"dot/Math.exp(11*Math.pow(dist,4))",false,96,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[12,65,"floor(random()*2)",false,48,"dot/Math.exp(11*Math.pow(dist,4))",true,24,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[10,66,"floor(random()*4/3)",false,24,"dot/Math.exp(11*Math.pow(dist,4))",true,20,"dist"];document.getElementById("useOct3").checked=true;octaveData[3]=[32,67,"floor(random()*4/3)",false,64,"dot/Math.exp(11*Math.pow(dist,4))",false,12,"dist"];document.getElementById("useOct4").checked=true;octaveData[4]=[14,68,"floor(random()*4/3)",false,64,"dot/Math.exp(11*Math.pow(dist,4))",true,28,"dist"];document.getElementById('combineGen').value="var hex1=Math.max(4*sqr(nWor(1,0,x,y)),nVor(1,0,x,y)/6); var hex2=Math.max(4*sqr(nWor(2,0,x,y)),nVor(2,0,x,y)/6); var hex3=Math.max(4*sqr(nWor(4,0,x,y)),nVor(4,0,x,y)/6); var blob1=pow(2*Math.max(0,nSum(0,x,y)-1/2),1/8); var blob2=pow(2*Math.max(0,nSum(3,x,y)-1/2),1/8); red=255;green=200; if(blob2>0){height=128*(1+blob2*hex3);} else if(blob1>0){height=128*(1/2+blob1*hex1);} else{height=128*hex2;} red=2*height;green=height*8/5; ;;;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
function setGlass() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0,0.31,1.75,0.08,0.08);document.getElementById("useOct0").checked=true;octaveData[0]=[32,64,"[randomRange(0,255),randomRange(0,255),randomRange(0,255),x,y]",false,4,"dot/Math.exp(11*Math.pow(dist,4))",false,96,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[8,65,"[randomRange(0,255),randomRange(0,255),randomRange(0,255)]",false,24,"dot/Math.exp(11*Math.pow(dist,4))",false,24,"dist"];document.getElementById('combineGen').value=" var p1=nVor(0,0,x,y); var p2=nVor(0,1,x,y); var x1=p1[3];var y1=p1[4]; var x2=p2[3]; var y2=p2[4]; if(abs(x1-x2)>(w/2)){if (x2>x1){x2-=w}else{x2+=w}} if(abs(x1-x)>(w/2)){if (x2>x){x1-=w;x2-=w}else{x1+=w;x2+=w}} if(abs(y1-y2)>(h/2)){if (y2>y1){y2-=h}else{y2+=h}} if(abs(y1-y)>(h/2)){if (y2>y){y1-=h;y2-=h}else{y1+=h;y2+=h}} var poly1=abs(((y1-y2)*(y-(y1+y2)/2)+(x1-x2)*(x-(x1+x2)/2))/32); p3=nVor(1,0,x,y); p4=nVor(1,1,x,y); red=(3*(p1[0]*2+p2[0])/3+(p3[0]*2+p4[0])/3)/4; green=(3*(p1[1]*2+p2[1])/3+(p3[1]*2+p4[1])/3)/3; blue=(3*(p1[2]*2+p2[2])/3+(p3[2]*2+p4[2])/3)/4; height=(poly1-4)*(1+(1-abs(2*nSum(1,x,y)-1)/2)); if (poly1<4){var gray=16*(4-poly1);red=gray;green=gray;blue=gray;height=(4-poly1)*(8*nSum(1,4*x,4*y))};;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
|
|
function setChip() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0,0.31,1.31,0.2,0.2);document.getElementById("useOct0").checked=true;octaveData[0]=[32,64,"floor(2*random())",false,4,"dot/Math.exp(11*Math.pow(dist,4))",false,96,"abs(x)+abs(y)"];document.getElementById("useOct1").checked=true;octaveData[1]=[32,65,"[x,y]",false,24,"dot/Math.exp(11*Math.pow(dist,4))",false,64,"dist"];document.getElementById('combineGen').value="var wire=floor(2*sin(64*(nWor(0,2,x,y)-nWor(0,1,x,y)))); var node=128*(Math.max(0,1/16-abs(Math.max(nWor(1,0,x,y),1/16)-1/12))); var core=nVor(0,0,x,y)*Math.min(Math.max(128*(nWor(0,1,x,y)-nWor(0,0,x,y)-1/6),0),4); if (wire==1){red=200;green=200;blue=128} else {green=64-16*(x%2)*(y%2)} if (Math.max(core,node)>0){red=200;green=200;blue=160} height=Math.max(core,node); if (nWor(1,0,x,y)<1/24){red=0;green=0;blue=0;};;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
function setWood() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0,0.08,0.63,0.09,0.09);document.getElementById("useOct0").checked=true;octaveData[0]=[32,64,"floor(2*random())",false,64,"dot/Math.exp(11*Math.pow(dist,4))",false,96,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[16,65,"[x,y]",false,32,"dot/Math.exp(11*Math.pow(dist,4))",false,64,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[4,66,"floor(random()*4/3)",false,8,"dot/Math.exp(11*Math.pow(dist,4))",true,8,"dist"];document.getElementById('combineGen').value="var rings=(6*((y/32+nSum(0,x,y)+nSum(1,x,y)/2+2*pow(1-nWor(0,0,x,y),12))%(1/4)+1/16)); var nx=x+4*cos(rings); var ny=y+16*sin(rings); var light=nSum(2,nx,ny); var shade; if (floor(rings)==1){shade=2*light} else {shade=nSum(2,4*x,4*y)/2} red=187*shade;green=85*shade; height=rings*64;;;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
function setWall() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0.09,0.13,3.38,0.27,0.27);document.getElementById("useOct0").checked=true;octaveData[0]=[32,64,"abs(y)+x*x",false,64,"dot/Math.exp(11*Math.pow(dist,4))",false,96,"sqrt(y*y+x*x*x*x*x*x)"];document.getElementById("useOct1").checked=true;octaveData[1]=[16,65,"[x,y]",false,32,"dot/Math.exp(11*Math.pow(dist,4))",false,48,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[8,66,"floor(random()*4/3)",false,16,"dot/Math.exp(11*Math.pow(dist,4))",false,24,"dist"];document.getElementById('combineGen').value="var stone=pow(4*(nWor(0,1,x,y)-nWor(0,0,x,y)),1/2)*(1+nWor(1,1,x,y)*(1+nWor(2,1,x,y)*(1+nWor(1,2,2*x,2*y)*(1+nWor(2,2,2*x,2*y))))); var stone2=pow(4*(nWor(0,1,x,y+1)-nWor(0,0,x,y+1)),1/2)*(1+nWor(1,1,x,y+1)*(1+nWor(2,1,x,y+1)*(1+nWor(1,2,2*x,2*y+2)*(1+nWor(2,2,2*x,2*y+2))))); var slope=8*(stone2-stone); var moss=stone*slope*(1-nWor(1,0,x,y))*(2-nWor(2,0,x,y))-1/2; red=64;green=64;blue=56; if (moss>0){red=16;green=8*sqrt(Math.max(64*moss,72));blue=16} height=128*stone;;;;;;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
function setAlgae() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0,0.12,1.17,0,0);document.getElementById("useOct0").checked=true;octaveData[0]=[32,64,"[x,y]",false,64,"dot/Math.exp(11*Math.pow(dist,4))",false,128,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[16,65,"[x,y]",false,32,"dot/Math.exp(11*Math.pow(dist,4))",false,64,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[8,66,"[x,y]",false,16,"dot/Math.exp(11*Math.pow(dist,4))",false,32,"dist"];document.getElementById("useOct3").checked=true;octaveData[3]=[4,67,"[x,y]",false,8,"dot/Math.exp(11*Math.pow(dist,4))",false,16,"dist"];document.getElementById('combineGen').value="var ex=1/3; var strands=Math.max(4/3-(pow(abs(2*nSum(0,x,y)-1),ex)+pow(abs(2*nSum(1,x,y)-1),ex)/2+pow(abs(2*nSum(2,x,y)-1),ex)/3+pow(abs(2*nSum(3,x,y)-1),ex)/4),0); var cells=(2-(6*nWor(0,0,x,y)))*(3/2-(6*nWor(1,0,x,y)))*(3/2-(6*nWor(2,0,x,y)))*(3/2-(6*nWor(3,0,x,y))); var alga=Math.max(3*strands,cells/2); red=139*(1-alga/2);green=222*(1-alga)+128*alga;blue=199*(Math.max(1-alga*2,0)); height=128*alga;;;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
function setMountain() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0.5,0.22,1.21,0.3,0.3);document.getElementById("useOct0").checked=true;octaveData[0]=[64,64,"[x,y]",false,128,"dot/Math.exp(11*Math.pow(dist,4))",false,192,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[32,65,"[x,y]",false,64,"dot/Math.exp(11*Math.pow(dist,4))",false,96,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[16,66,"[x,y]",false,32,"dot/Math.exp(11*Math.pow(dist,4))",false,48,"dist"];document.getElementById("useOct3").checked=true;octaveData[3]=[8,67,"[x,y]",false,16,"dot/Math.exp(11*Math.pow(dist,4))",false,24,"dist"];document.getElementById("useOct4").checked=true;octaveData[4]=[4,68,"[x,y]",false,8,"dot/Math.exp(11*Math.pow(dist,4))",false,12,"dist"];document.getElementById("useOct5").checked=true;octaveData[5]=[4,69,"[x,y]",false,24,"dist",false,24,"-atmost(abs(dot),1/32)*(1-dist)"];document.getElementById('combineGen').value="var mount1=nSum(0,x,y)*(1+nSum(1,x,y)*(1+nSum(2,x,y)*(1+nSum(3,x,y)*(1+nSum(4,x,y)+(1+nSum(5,x,y)))))); var mount2=nSum(0,x+1,y)*(1+nSum(1,x+1,y)*(1+nSum(2,x+1,y)*(1+nSum(3,x+1,y)*(1+nSum(4,x+1,y)+(1+nSum(5,x+1,y)))))); var mount3=nSum(0,x,y+1)*(1+nSum(1,x,y+1)*(1+nSum(2,x,y+1)*(1+nSum(3,x,y+1)*(1+nSum(4,x,y+1)+(1+nSum(5,x,y+1)))))); var steep=64*sqrt(sqr(mount1-mount2)+sqr(mount1-mount3)); var grass=1-nWor(5,0,2*x,2*y); height=128*mount1; if (steep<2){if (height<96){green=96*grass;red=32*grass}else{red=128*grass;green=128*grass;blue=128*grass}} else{red=128;green=128;blue=128}; ;;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
function setLunar() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,true,true,0.38,0.27,0.9,0.25,0.25);document.getElementById("useOct0").checked=true;octaveData[0]=[48,64,"floor(2*random())",false,96,"dot/Math.exp(11*Math.pow(dist,4))",false,128,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[24,65,"floor(2*random())",false,48,"dot/Math.exp(11*Math.pow(dist,4))",false,48,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[12,66,"floor(2*random())",false,24,"dot/Math.exp(11*Math.pow(dist,4))",false,24,"dist"];document.getElementById("useOct3").checked=true;octaveData[3]=[24,67,"[x,y]",false,24,"(11*dist*dist*dist*dist-1/8)/exp(14*dist*dist)",false,72,"dist"];document.getElementById('combineGen').value="var crater1=1*nSum(3,x,y)/4-1/8; var rough=(1-nWor(3,2,2*x,2*y))*(1-nWor(3,1,3*x,3*y))*(nWor(3,0,x,y)); var crater2=1.5*nVor(2,0,x,y)*Math.min(sqr(nWor(2,0,x,y))-1/24,0)/2+nVor(1,0,x,y)*Math.min(sqr(nWor(1,0,x,y))-1/24,0); var terra=Math.max((4/3+nSum(0,x,y))/2,sqrt(nSum(1,x,y)+nSum(2,x,y)/2+crater1)); height=128*(terra*(1+rough/2)+crater2);;"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
function setMartian() |
|
{cancelOct();document.getElementById('loadsave').value=`setGlobals(128,128,false,true,0.36,0.18,0.97,0.07,0.07);document.getElementById("useOct0").checked=true;octaveData[0]=[64,64,"[x,y]",false,128,"dot/Math.exp(11*Math.pow(dist,4))",false,192,"dist"];document.getElementById("useOct1").checked=true;octaveData[1]=[32,65,"[x,y]",false,64,"dot/Math.exp(11*Math.pow(dist,4))",false,96,"dist"];document.getElementById("useOct2").checked=true;octaveData[2]=[16,66,"floor(1.1*random())",false,32,"dot/Math.exp(11*Math.pow(dist,4))",false,48,"dist"];document.getElementById("useOct3").checked=true;octaveData[3]=[8,67,"[x,y]",false,16,"dot/Math.exp(11*Math.pow(dist,4))",false,24,"dist"];document.getElementById("useOct4").checked=true;octaveData[4]=[4,68,"[x,y]",false,8,"dot/Math.exp(11*Math.pow(dist,4))",false,12,"dist"];document.getElementById('combineGen').value="var distort=6*(nSum(0,x,y)+nSum(1,x,y)/2+nSum(2,x,y)/4+nSum(3,x,y)/8+nSum(4,x,y)/16); var nx=x+32*cos(distort); var ny=y+32*sin(distort); var terra=(nSum(0,nx,ny)+nSum(1,nx,ny)/2+nSum(2,nx,ny)/4+nSum(3,nx,ny)/8); terra=nSum(0,nx,ny)*(1+nSum(1,nx,ny)*(1+nSum(2,nx,ny)*(1+nSum(3,nx,ny)*(1+nSum(4,nx,ny)/2)/2)/2)/2); var rocks=(4*nVor(2,0,x+nx/2,y+ny/2)*(nWor(2,1,x+nx/2,y+ny/2)-nWor(2,0,x+nx/2,y+ny/2))+nWor(1,2,x,y)/2)*(1-nWor(2,2,x,y))*(1-nWor(3,2,x,y))*(1-nWor(4,2,x,y)); height=128*(terra+2*rocks); if (nVor(2,0,x+nx/2,y+ny/2)==1){shade=4*(1/16+rocks);red=shade*86;green=shade*81;blue=shade*75} else {shade=12*(1/16+rocks);red=shade*199;green=shade*133;blue=shade*101};"`; |
|
executeString(document.getElementById('loadsave').value);openOct2(0);genOctaves(); |
|
} |
|
function setRandom() |
|
{ |
|
var rand=Math.floor(16*Math.random()) |
|
switch (rand) |
|
{ |
|
case 0:setSand();break; |
|
case 1:setGrass();break; |
|
case 2:setBricks();break; |
|
case 3:setStones();break; |
|
case 4:setAgate();reak; |
|
case 6:setLava();break; |
|
case 7:setHive();break; |
|
case 8:setGlass();break; |
|
case 9:setChip();break; |
|
case 10:setWood();break; |
|
case 12:setAlgae();break; |
|
case 13:setMountain();break; |
|
case 14:setLunar();break; |
|
case 15:setMartian();break; |
|
default:setMartian();break; |
|
} |
|
} |
|
setRandom(); |