Snowflake v2
by XGundam05
HTML
<div>
<canvas id='canv' width="256" height="256"></canvas>
<div id="seed"></div>
</div>
CSS
canvas{
border: solid 1px black;
}
JavaScript
DoFlake(document.getElementById('canv'));
function DoFlake(canvas){
var width = canvas.width;
var height = canvas.height;
var ctx = canvas.getContext('2d');
var fill = ctx.fillStyle;
ctx.fillStyle = '#82b2f5';
ctx.fillRect(0,0,width,height);
ctx.fillStyle = fill;
var baseFlake = document.createElement('canvas'); baseFlake.width = 128; baseFlake.height = 32;
var baseCtx = baseFlake.getContext('2d');
baseCtx.fillStyle = '#ffffff';
var detailFlake = document.createElement('canvas'); detailFlake.width = 128; detailFlake.height = 32;
var detailCtx = detailFlake.getContext('2d');
detailCtx.fillStyle = '#dddddd';
var veinFlake = document.createElement('canvas'); veinFlake.width = 128; veinFlake.height = 32;
var veinCtx = veinFlake.getContext('2d');
veinCtx.fillStyle = baseCtx.fillStyle;
var date = new Date();
document.getElementById('seed').innerHTML = date.getTime();
var noise = new ImprovedPerlin(date.getTime()); //Test Seed: 5588446, Interesting Seed: 1388681756253
var wDiv = 1/64;
var y = 7/32;
var z = 2/11;
for(var x = 0; x < 128; x++){
var h = 32 - (x * 32 / 128);
h += 16 * noise.Noise(4 * x * wDiv, y, z);
h += 8 * noise.Noise(8 * x * wDiv, y, z);
h += 4 * noise.Noise(16 * x * wDiv, y, z);
h += 2 * noise.Noise(32 * x * wDiv, y, z);
h += 1 * noise.Noise(64 * x * wDiv, y, z);
baseCtx.fillRect(x, 0, 1, h);
detailCtx.fillRect(x, 0, 1, h*0.5);
veinCtx.fillRect(x, 0, 1, h*0.25);
}
ctx.translate(128,128);
var angle = Math.PI / 3;
for(var i = 0; i < 6; i++){
ctx.rotate(angle);
ctx.drawImage(baseFlake, 0, 0);
ctx.scale(1, -1)
ctx.drawImage(baseFlake, 0, 0);
ctx.scale(1, -1);
}
for(var i = 0; i < 6; i++){
ctx.rotate(angle);
ctx.drawImage(detailFlake, 0, 0);
ctx.scale(1,...