This document explains how to use and customize the animated geometric cube pattern background for your streaming overlay or web project.
This HTML/CSS/JavaScript file creates a mesmerizing animated background with tessellated cubes that create an optical illusion where it’s ambiguous which parts stick “out” and which parts stick “in.” The animation includes smooth transitions that continuously change your perception of the cube wall. It’s designed for streaming overlays, website backgrounds, or any digital content that needs a dynamic geometric backdrop.
This document explains how to use and customize the animated geometric cube pattern background for your streaming overlay or web project.
.html
extension (e.g., geometric-cube-background.html
).The background can be easily customized by editing the HTML file in any text editor. Here are the main aspects you can change:
Find the background
CSS style in the setup()
or draw()
function:
background(10, 10, 30);
You can change these RGB values to any color you like. Some examples:
background(25, 0, 50);
background(20, 20, 20);
background(0, 20, 30);
Find the config
object at the top of the JavaScript section:
const config = {
cubeSize: 40, // Size of each cube
gridSize: 24, // Calculated dynamically for coverage
animationSpeed: 0.0006, // Speed of pattern change
rotationAmount: 0.01, // Amount of subtle rotation
drawUpdateFrequency: 30 // Only update the display every 30 frames
};
Here’s what each property does:
Find the baseColors
object in the drawCube
function:
let baseColors = {
topOut: color(120, 140, 170),
leftOut: color(80, 100, 130),
rightOut: color(100, 120, 150),
topIn: color(100, 120, 150),
leftIn: color(120, 140, 170),
rightIn: color(80, 100, 130)
};
You can change these RGB values to create different color schemes for the cubes:
let baseColors = {
topOut: color(170, 140, 120),
leftOut: color(130, 100, 80),
rightOut: color(150, 120, 100),
topIn: color(150, 120, 100),
leftIn: color(170, 140, 120),
rightIn: color(130, 100, 80)
};
let baseColors = {
topOut: color(200, 200, 200),
leftOut: color(120, 120, 120),
rightOut: color(160, 160, 160),
topIn: color(160, 160, 160),
leftIn: color(200, 200, 200),
rightIn: color(120, 120, 120)
};
let baseColors = {
topOut: color(100, 170, 150),
leftOut: color(60, 130, 110),
rightOut: color(80, 150, 130),
topIn: color(80, 150, 130),
leftIn: color(100, 170, 150),
rightIn: color(60, 130, 110)
};
The pattern of which cubes appear to stick “out” vs “in” is controlled by the wave functions in drawCubeWall()
:
let wave1 = cos((x * 0.12 + y * 0.1) + ambiguityPhase * 0.4);
let wave2 = sin((x * 0.09 - y * 0.11) + ambiguityPhase * 0.3);
let wave3 = cos((x * 0.06 + y * 0.13) - ambiguityPhase * 0.35);
To create different patterns:
If you want to stop the animation but maintain the current pattern:
// Change this line:
ambiguityPhase += config.animationSpeed;
// To this:
// ambiguityPhase += 0; // Frozen pattern
For websites (not OBS), you could add code that changes the pattern or colors when clicked:
function mousePressed() {
// Generate new random colors
// or
// Reset ambiguityPhase
// or
// Change animation direction
}
cubeSize
value) will create fewer cubes and better performance.gridSize
lower, you’ll have fewer cubes to render.If the background doesn’t appear or has issues:
cubeSize
and increase drawUpdateFrequency
.This background should work with: