Skip to content

Instantly share code, notes, and snippets.

@wyattowalsh
Last active January 10, 2025 03:38
Show Gist options
  • Save wyattowalsh/22e3b9000e61ced43b3bfc308c974c9b to your computer and use it in GitHub Desktop.
Save wyattowalsh/22e3b9000e61ced43b3bfc308c974c9b to your computer and use it in GitHub Desktop.
// Final Production Version: p5.js sketch for exporting a highly detailed SVG background
let svg;
function setup() {
svg = createGraphics(windowWidth, 300, SVG);
noLoop();
}
function draw() {
// Gradient Background with Complex Color Layers
for (let y = 0; y < svg.height; y++) {
let inter = map(y, 0, svg.height, 0, 1);
let c = lerpColor(color('#6a9fb5'), color('#b5a66a'), inter);
svg.stroke(c);
svg.line(0, y, svg.width, y);
}
// Starry effect with varying brightness
for (let i = 0; i < 200; i++) {
let x = random(svg.width);
let y = random(svg.height);
let starSize = random(1, 4);
svg.noStroke();
svg.fill(255, random(80, 200));
svg.ellipse(x, y, starSize, starSize);
}
// Dynamic Wave Patterns with Gradient Strokes
for (let i = 0; i < 7; i++) {
let waveHeight = random(20, 100);
let waveOffset = random(-100, 100);
svg.strokeWeight(random(0.8, 2));
svg.stroke(lerpColor(color(255, 255, 255, 50), color(255, 255, 255, 100), random()));
svg.noFill();
svg.beginShape();
for (let x = 0; x < svg.width; x += 10) {
let y = svg.height / 2 + sin((x + waveOffset) * 0.015) * waveHeight;
svg.vertex(x, y);
}
svg.endShape();
}
// Radial Gradient Circles for Focal Elements
for (let i = 0; i < 30; i++) {
let x = random(svg.width);
let y = random(svg.height);
let maxSize = random(30, 120);
for (let r = maxSize; r > 0; r -= 6) {
let alpha = map(r, 0, maxSize, 60, 0);
svg.fill(255, 255, 255, alpha);
svg.noStroke();
svg.ellipse(x, y, r, r);
}
}
// Add Glittering Particles for a Magical Effect
for (let i = 0; i < 80; i++) {
let px = random(svg.width);
let py = random(svg.height);
let pSize = random(2, 5);
let glitterColor = lerpColor(color(255, 255, 255, 150), color(255, 200, 100, 180), random());
svg.fill(glitterColor);
svg.noStroke();
svg.ellipse(px, py, pSize, pSize);
}
// Subtle Geometric Patterns
for (let i = 0; i < 10; i++) {
let x = random(svg.width / 4, (svg.width / 4) * 3);
let y = random(svg.height / 4, (svg.height / 4) * 3);
let size = random(50, 100);
svg.noFill();
svg.stroke(255, 150);
svg.strokeWeight(0.5);
svg.beginShape();
for (let j = 0; j < 6; j++) {
let angle = TWO_PI / 6 * j;
let vx = x + cos(angle) * size;
let vy = y + sin(angle) * size;
svg.vertex(vx, vy);
}
svg.endShape(CLOSE);
}
// Save SVG file
save(svg, "bg.svg");
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="512" height="512" x="0" y="0" viewBox="0 0 511.999 511" style="enable-background:new 0 0 512 512" xml:space="preserve"><g><path fill="#686c83" d="M54 392.012v5.62l53-5.093v-13.078c0-23.09 4.453-45.965 13.113-67.367l-29.402-48.801A244.038 244.038 0 0 0 54 392.012zm0 0" opacity="1" data-original="#686c83"></path><path fill="#c9f3ff" d="M102.71 422.54c-12.937-12.938-33.917-12.938-46.855 0-12.613 12.612-32.859 12.925-45.855.948v29.309c12.938 12.937 33.918 12.937 46.855 0 12.938-12.942 33.918-12.942 46.856 0 12.613 12.613 32.86 12.926 45.86.95v-31.208c-12.942 12.938-33.919 12.938-46.86 0zm0 0" opacity="1" data-original="#c9f3ff"></path><path fill="#36d28f" d="M272.766 19.012 152.418 88.496l-52.27 120.3 49.72 86.118 211.644-122.191-38.754-67.121zm0 0" opacity="1" data-original="#36d28f"></path><path fill="#ffffff" d="M449.707 294.477H502v-87.414l-71.195-99.903h-69.293v187.317zm0 0" opacity="1" data-original="#ffffff"></path><path fill="#c9f3ff" d="M452.828 138.383h-20.61v67.18h68.708zm0 0" opacity="1" data-original="#c9f3ff"></path><g fill="#898998"><path d="M208.363 294.477c0 15.52-12.582 28.101-28.097 28.101-15.52 0-28.102-12.582-28.102-28.101 0-15.516 12.582-28.098 28.102-28.098 15.515 0 28.097 12.582 28.097 28.098zm0 0" fill="#898998" opacity="1" data-original="#898998"></path><path d="M264.559 294.477c0 15.52-12.582 28.101-28.102 28.101-15.516 0-28.098-12.582-28.098-28.101 0-15.516 12.582-28.098 28.098-28.098 15.52 0 28.102 12.582 28.102 28.098zM446.844 294.477c0 15.52-12.578 28.101-28.098 28.101-15.516 0-28.098-12.582-28.098-28.101 0-15.516 12.582-28.098 28.098-28.098 15.52 0 28.098 12.582 28.098 28.098zm0 0" fill="#898998" opacity="1" data-original="#898998"></path></g><path fill="#ffc66c" d="M183.168 347.578H502V462.5H183.168zm0 0" opacity="1" data-original="#ffc66c"></path><path d="M502 304.48c5.523 0 10-4.48 10-10v-87.417c0-2.063-.664-4.122-1.855-5.801l-71.196-99.903a9.998 9.998 0 0 0-8.144-4.195h-69.293c-5.524 0-10 4.477-10 10v28.238l-75-129.902c-2.762-4.781-8.875-6.422-13.66-3.66L112.754 88.5a10.005 10.005 0 0 0-4.172 4.676L56.309 213.48a10 10 0 0 0 .511 8.985l7.434 12.875c-31.723 42.652-49.445 94.902-50.215 148.058-3.668-1.617-8.105-.933-11.11 2.07-3.906 3.903-3.906 10.235 0 14.141 8.145 8.149 18.977 12.633 30.5 12.633 11.52 0 22.352-4.484 30.5-12.633 9.02-9.02 23.696-9.015 32.716 0 8.144 8.149 18.976 12.633 30.5 12.633 5.21 0 10.277-.926 15.023-2.687v37.375c-9.078 7.777-22.793 7.386-31.383-1.203-16.816-16.817-44.18-16.817-61 0-9.02 9.02-23.695 9.02-32.715 0-3.906-3.903-10.238-3.903-14.14 0-3.907 3.906-3.907 10.238 0 14.144 16.816 16.813 44.18 16.813 61 0 9.02-9.023 23.691-9.023 32.715 0 8.406 8.406 19.453 12.61 30.5 12.61a43.292 43.292 0 0 0 17.308-3.618 9.976 9.976 0 0 0 7.715 3.64H502c5.523 0 10-4.48 10-10V322.579c0-5.523-4.477-10-10-10h-49.738a37.832 37.832 0 0 0 3.242-8.101H502zm-19.406-107.417h-67.375v-48.68h32.683zM371.512 117.16h54.14l7.996 11.223h-28.43c-5.523 0-10 4.476-10 10v68.68c0 5.523 4.477 10 10 10H492v67.417h-36.496c-4.406-16.171-19.211-28.097-36.758-28.097s-32.351 11.926-36.758 28.097h-10.476zM162.164 294.48c0-9.98 8.121-18.097 18.102-18.097 9.976 0 18.097 8.117 18.097 18.097s-8.12 18.098-18.097 18.098c-9.98 0-18.102-8.121-18.102-18.098zm120.512-64.695 54.691 54.692h-64.152c-4.39-16.125-19.13-28.028-36.61-28.094zm-64.313 64.695c0-9.98 8.117-18.097 18.098-18.097 9.976 0 18.098 8.117 18.098 18.097s-8.122 18.098-18.098 18.098c-9.98 0-18.098-8.121-18.098-18.098zm54.852 10h108.773a37.881 37.881 0 0 0 3.242 8.098H269.977a37.87 37.87 0 0 0 3.238-8.098zm78.297-34.144-50.907-50.902 50.907-29.391zM125.609 104.172 264.191 24.16l14.27 24.715-65.137 37.707c-4.777 2.766-6.41 8.887-3.64 13.664a9.991 9.991 0 0 0 13.664 3.645l65.113-37.696 59.39 102.868-154.972 89.472a37.897 37.897 0 0 0-12.613-2.156c-18.84 0-34.52 13.75-37.559 31.738-1.043.211-2.07.582-3.043 1.14l-15.887 9.177-47.117-81.606zM49.785 385.469c-4.234 4.23-9.824 6.601-15.785 6.746v-5.203c0-47.207 14.57-93.809 41.238-132.64l33.817 58.57c-7.621 20.316-11.653 41.57-12.02 63.288-15.683-6.59-34.496-3.515-47.25 9.239zm77.356 6.773c-3.579 0-7.02-.828-10.141-2.355V379.46c0-20.773 3.754-41.094 11.148-60.461l16.98-9.8a37.882 37.882 0 0 0 2.302 4.57 9.992 9.992 0 0 0-5.262 8.808v64.098a22.967 22.967 0 0 1-15.027 5.566zM492 403.5H367c-5.523 0-10 4.48-10 10 0 5.523 4.477 10 10 10h125v29H162.164V332.578H492zm-91.352-109.02c0-9.98 8.122-18.097 18.098-18.097 9.98 0 18.098 8.117 18.098 18.097s-8.117 18.098-18.098 18.098c-9.976 0-18.098-8.121-18.098-18.098zm0 0" fill="#000000" opacity="1" data-original="#000000"></path><path d="M87.36 298.43a10.08 10.08 0 0 0-7.07-2.93c-2.642 0-5.212 1.07-7.071 2.93a10.037 10.037 0 0 0-2.93 7.07c0 2.633 1.059 5.21 2.93 7.07a10.08 10.08 0 0 0 7.07 2.93 10.1 10.1 0 0 0 7.07-2.93 10.073 10.073 0 0 0 2.93-7.07c0-2.629-1.07-5.207-2.93-7.07zM63.988 333.012c-2.629 0-5.21 1.07-7.07 2.93s-2.93 4.44-2.93 7.07c0 2.629 1.07 5.21 2.93 7.07s4.441 2.93 7.07 2.93c2.63 0 5.211-1.07 7.07-2.93s2.93-4.441 2.93-7.07c0-2.63-1.07-5.211-2.93-7.07s-4.44-2.93-7.07-2.93zM327.078 403.5a10.08 10.08 0 0 0-7.07 2.93 10.087 10.087 0 0 0-2.93 7.07c0 2.633 1.07 5.21 2.93 7.07 1.87 1.86 4.441 2.93 7.07 2.93s5.211-1.07 7.082-2.93a10.061 10.061 0 0 0 2.918-7.07c0-2.629-1.058-5.207-2.918-7.07a10.107 10.107 0 0 0-7.082-2.93zM183.64 125.148c2.637 0 5.208-1.066 7.079-2.93a10.051 10.051 0 0 0 2.922-7.07c0-2.628-1.063-5.207-2.922-7.066a10.109 10.109 0 0 0-7.078-2.934c-2.633 0-5.203 1.07-7.07 2.934a10.054 10.054 0 0 0-2.93 7.066c0 2.645 1.066 5.211 2.93 7.07a10.056 10.056 0 0 0 7.07 2.93zm0 0" fill="#000000" opacity="1" data-original="#000000"></path></g></svg>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment