try apply and integrate and output full working code.: ("Genetic algorithm for “getDeviation” function:

1. Define a target shape as a set of edges between vertices.
2. Create an initial population of 100 deviation values, randomly sampled from a normal distribution with mean 0 and standard deviation 0.1.
3. Evaluate each deviation value by measuring how closely the resulting shape matches the target shape, using the average squared distance between the vertices in the rendered shape and the target shape as the evaluation score.
4. Select the top 30% of deviation values based on their evaluation scores, and generate 30 new deviation values by randomly sampling from their corresponding normal distributions.
5. Select the remaining 70% of deviation values randomly, and generate 70 new deviation values by recombining two randomly chosen deviation values from the previous generation using uniform crossover.
6. Mutate each new deviation value by adding a random value sampled from a normal distribution with mean 0 and standard deviation p, where p decreases linearly from 0.05 to 0.01 over generations.
7. Repeat steps 3-6 for a certain number of generations (e.g. 50), or until the average evaluation score reaches a satisfactory threshold (e.g. 0.05).

Genetic algorithm for “cpDist” function:

1. Define a target shape curvature as a function of the angle between adjacent edges.
2. Create an initial population of 100 control point distances, randomly sampled from a normal distribution with mean 0.25 and standard deviation 0.05.
3. Evaluate each control point distance by measuring how closely the resulting shape curvature matches the target shape curvature, using the average squared difference between the rendered shape curvature and the target shape curvature as the evaluation score.
4. Select the top 30% of control point distances based on their evaluation scores, and generate 30 new control point distances by randomly sampling from their corresponding normal distributions.
5. Select the remaining 70% of control point distances randomly, and generate 70 new control point distances by recombining two randomly chosen control point distances from the previous generation using uniform crossover.
6. Mutate each new control point distance by adding a random value sampled from a normal distribution with mean 0 and standard deviation p, where p decreases linearly from 0.1 to 0.01 over generations.
7. Repeat steps 3-6 for a certain number of generations (e.g. 50), or until the average evaluation score reaches a satisfactory threshold (e.g. 0.01).
"). integrate to: ("const canvas=document.createElement("canvas");canvas.width=window.innerWidth;canvas.height=window.innerHeight;document.body.appendChild(canvas);const ctx=canvas.getContext("2d");const vertices=[[0,0,0],[0,1,0],[1,1,0],[1,0,0],[0,0,1],[0,1,1],[1,1,1],[1,0,1]];const edges=[[0,1],[1,2],[2,3],[3,0],[0,4],[1,5],[2,6],[3,7],[4,5],[5,6],[6,7],[7,4]];const scale=.02;const zoom=1;const offsetX=.5;const offsetY=.5;function rotateX(angle){const c=Math.cos(angle);const s=Math.sin(angle);return[[1,0,0],[0,c,-s],[0,s,c]]}function rotateY(angle){const c=Math.cos(angle);const s=Math.sin(angle);return[[c,0,s],[0,1,0],[-s,0,c]]}function rotateZ(angle){const c=Math.cos(angle);const s=Math.sin(angle);return[[c,-s,0],[s,c,0],[0,0,1]]}function project(vertex,scale,offsetX,offsetY,zoom){const[x,y,z]=vertex;const posX=(x-offsetX)*scale;const posY=(y-offsetY)*scale;const posZ=z*scale;return[posX*(zoom+posZ)+canvas.width/2,posY*(zoom+posZ)+canvas.height/2]}function transform(vertex,rotationMatrix){const[x,y,z]=vertex;const[rowX,rowY,rowZ]=rotationMatrix;return[x*rowX[0]+y*rowX[1]+z*rowX[2],x*rowY[0]+y*rowY[1]+z*rowY[2],x*rowZ[0]+y*rowZ[1]+z*rowZ[2]]}function extraterrestrialTransformation(vertex,frequency,amplitude){const[x,y,z]=vertex;const cosX=Math.cos(x*frequency)*amplitude;const cosY=Math.cos(y*frequency)*amplitude;const cosZ=Math.cos(z*frequency)*amplitude;return[x+cosX,y+cosY,z+cosZ]}let angleX=0;let angleY=0;let angleZ=0;function getDeviation(maxDeviation){const t=Date.now()/1e3;const frequency=1/5;const amplitude=maxDeviation/2;const deviation=Math.sin(t*frequency)*amplitude;return deviation.toFixed(3)}function render(){ctx.fillStyle="#FFF";ctx.fillRect(0,0,canvas.width,canvas.height);const rotX=rotateX(angleX);const rotY=rotateY(angleY);const rotZ=rotateZ(angleZ);const frequency=1;const amplitude=.08;const transformedVertices=vertices.map(vertex=>{const extraterrestrialVertex=extraterrestrialTransformation(vertex,frequency,amplitude);const cx=extraterrestrialVertex[0]-offsetX;const cy=extraterrestrialVertex[1]-offsetY;const cz=extraterrestrialVertex[2]-offsetY;const rotated=transform(transform(transform([cx,cy,cz],rotX),rotY),rotZ);return[rotated[0]+offsetX,rotated[1]+offsetY,rotated[2]+offsetY]});const projectedVertices=transformedVertices.map(vertex=>project(vertex,canvas.height*scale,offsetX,offsetY,zoom));ctx.lineWidth=6;ctx.strokeStyle="hsla("+(angleX+angleY)*100+", 100%, 50%, 0.8)";ctx.beginPath();for(let edge of edges){const[a,b]=edge;const[x1,y1]=projectedVertices[a];const[x2,y2]=projectedVertices[b];const dist=Math.sqrt((x2-x1)**2+(y2-y1)**2);const angle=Math.atan2(y2-y1,x2-x1);const cpDist=.25*dist;const cpX=(x1+x2)/2+cpDist*Math.cos(angle-Math.PI/2)*getDeviation(5);const cpY=(y1+y2)/2+cpDist*Math.sin(angle-Math.PI/2)*getDeviation(5);ctx.moveTo(x1,y1);ctx.quadraticCurveTo(cpX,cpY,x2,y2)}ctx.stroke();angleX+=+getDeviation(.05);angleY+=+getDeviation(.05);angleZ+=+getDeviation(.05);requestAnimationFrame(render)}requestAnimationFrame(render);window.addEventListener("resize",()=>{canvas.width=window.innerWidth;canvas.height=window.innerHeight});")