createCanvas(windowWidth, windowHeight);
colorMode(HSB, 360, 100, 100, 100);
for (let i = 0; i < cloudCount; i++) {
let y = map(i, 0, cloudCount, 0, height / 2);
let cloud = createCloud(y);
stormCloud = createStormCloud(height / 4);
for (let i = 0; i < duneCount; i++) {
let y = map(i, 0, duneCount, height / 2, height);
let dune = createDune(y);
for (let cloud of clouds) {
strokeWeight(random(0.25, 3));
for (let pt of stormCloud) {
strokeWeight(random(2, 4));
for (let dune of dunes) {
let h = map(pt.y, pt.duneY, pt.duneY + duneHeight, 100, 30);
strokeWeight(random(0.25, 1.5));
let waveAmp = duneHeight * 0.35;
let waveFreq = TWO_PI / width;
for (let x = 0; x < width; x += 1) {
for (let yOff = 0; yOff < duneHeight; yOff += 1) {
let yNoise = noise(x * 0.001, (y + yOff) * 0.001) * duneHeight;
let yWave = waveAmp * sin(waveFreq * x);
yWave = waveAmp * sin(waveFreq * x + phase);
let pt = createVector(x, y + yOff + yNoise + yWave);
function createCloud(y) {
for (let x = 0; x < width; x += 5) {
for (let yOff = 0; yOff < cloudHeight; yOff += 5) {
let yNoise = noise(x * 0.01, (y + yOff) * 0.01) * cloudHeight;
let pt = createVector(x, y + yOff + yNoise);
function createStormCloudB(y) {
let cloudWidth = width / random(1.5, 2.5);
let amplitude = cloudWidth / 8;
for (let x = offsetX; x < offsetX + cloudWidth; x += 5) {
let widthVariation = amplitude * (noise(x * 0.01) * 2 - 1);
for (let yOff = 0; yOff < cloudHeight; yOff += 5) {
let yNoise = (noise(x * 0.01, (y + yOff) * 0.01) * 2 - 1) * cloudHeight;
let pt = createVector(x + widthVariation, y + yOff + yNoise);
function createStormCloud(y) {
let cloudWidth = width / 2;
let amplitude = cloudWidth / 8;
for (let x = offsetX; x < offsetX + cloudWidth; x += 5) {
let normalizedX = (x - offsetX) / cloudWidth;
let edgeFactor = Math.cos(normalizedX * PI);
let numPoints = max(1, map(edgeFactor, 0, 1, 1, 5));
let widthVariation = amplitude * (noise(x * 0.01) * 2 - 1);
for (let yOff = 0; yOff < cloudHeight; yOff += numPoints) {
let yNoise = (noise(x * 0.01, (y + yOff) * 0.01) * 2 - 1) * cloudHeight;
let pt = createVector(x + widthVariation, y + yOff + yNoise);