Background
roi-ui/backgroundFreeItem
A background component with various visual effects.
Install it
npx shadcn@latest add https://roiui.com/r/background.jsonSource
1"use client";2import type React from "react";3import { useEffect, useRef } from "react";4import styles from "./background.module.css";56const vertexShader = `7 attribute vec2 a_position;8 varying vec2 v_uv;910 void main() {11 v_uv = a_position * 0.5 + 0.5;12 gl_Position = vec4(a_position, 0.0, 1.0);13 }14`;1516const fragmentShader = `17 precision highp float;1819 uniform float u_time;20 uniform vec2 u_resolution;2122 uniform vec3 u_primaryColor;23 uniform vec3 u_secondaryColor;24 uniform vec3 u_backgroundColor;25 uniform float u_backgroundOpacity;2627 // Animation uniforms28 uniform float u_animationSpeed;29 uniform float u_noiseScale;30 uniform float u_intensity;3132 uniform float u_octaves;33 uniform float u_warpStrength;34 varying vec2 v_uv;3536 // Mathematical constants with high precision37 const float PI = 3.1415926535897932384626433832795;38 const float TAU = 6.2831853071795864769252867665590; // 2 * PI39 const float INV_PI = 0.3183098861837906715377675267450;40 const float SQRT_2 = 1.4142135623730950488016887242097;41 const float SQRT_3 = 1.7320508075688772935274463415059;42 const float PHI = 1.6180339887498948482045868343656; // Golden ratio4344 // Simplex noise constants - mathematically derived for optimal distribution45 const float F2 = 0.36602540378443864676372317075294; // (sqrt(3) - 1) / 246 const float G2 = 0.21132486540518713342105263157895; // (3 - sqrt(3)) / 647 const float G2_2 = 0.42264973081037426684210526315789; // 2 * G248 const float G2_MINUS_1 = -0.78867513459481286657894736842105; // 2 * G2 - 14950 // Improved permutation constants for better hash distribution51 const float PERM_MOD = 289.0;52 const float PERM_MUL = 34.0;53 const float PERM_ADD = 1.0;5455 // Optimized normalization constant for better noise range56 const float NOISE_SCALE = 70.0; // Improved from 130.0 for better dynamic range5758 // FBM configuration constants59 const float FBM_LACUNARITY = 2.0; // Frequency multiplier between octaves60 const float FBM_PERSISTENCE = 0.5; // Amplitude multiplier between octaves61 const float FBM_INITIAL_AMP = 0.5; // Starting amplitude6263 // Domain warping offset vectors - using irrational numbers for better distribution64 const vec2 WARP_OFFSET_1 = vec2(0.0, 0.0);65 const vec2 WARP_OFFSET_2 = vec2(5.12, 1.41); // Approximations of sqrt(26.2144) and sqrt(2)66 const vec2 WARP_OFFSET_3 = vec2(1.73, 9.17); // Approximations of sqrt(3) and sqrt(84.1)67// … truncated
Files it writes
More from Roi UI
All 123 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | Roi UI | Other | Free | no deps · 2 files | |
| Accordion (Tailwind)accordion-tailwind | Roi UI | Other | Free | no deps | |
| AI Chatai-chat | Roi UI | Other | Free | no deps · 2 files | |
| AI Chat (Tailwind)ai-chat-tailwind | Roi UI | Other | Free | no deps | |
| Alertalert | Roi UI | Other | Free | 1 dep · 2 files | |
| Alert Dialogalert-dialog | Roi UI | Other | Free | no deps · 2 files | |
| Alert Dialog (Tailwind)alert-dialog-tailwind | Roi UI | Other | Free | no deps | |
| Alert (Tailwind)alert-tailwind | Roi UI | Other | Free | 1 dep |
