My Website
Beautiful WebGL background
### Install color4bg Source: https://github.com/winterx/color4bg.js/blob/main/README.md Installation commands for different package managers. ```bash npm install color4bg ``` ```bash yarn add color4bg ``` ```bash pnpm add color4bg ``` -------------------------------- ### Basic Spinning Cube Example Source: https://github.com/winterx/color4bg.js/blob/main/src/ogl/README.md Renders a spinning white cube using Renderer, Camera, Transform, Box, Program, and Mesh. Requires basic setup for rendering and animation. ```javascript import { Renderer, Camera, Transform, Box, Program, Mesh } from 'ogl'; { const renderer = new Renderer(); const gl = renderer.gl; document.body.appendChild(gl.canvas); const camera = new Camera(gl); camera.position.z = 5; function resize() { renderer.setSize(window.innerWidth, window.innerHeight); camera.perspective({ aspect: gl.canvas.width / gl.canvas.height, }); } window.addEventListener('resize', resize, false); resize(); const scene = new Transform(); const geometry = new Box(gl); const program = new Program(gl, { vertex: /* glsl */ ` attribute vec3 position; uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } `, fragment: /* glsl */ ` void main() { gl_FragColor = vec4(1.0); } `, }); const mesh = new Mesh(gl, { geometry, program }); mesh.setParent(scene); requestAnimationFrame(update); function update(t) { requestAnimationFrame(update); mesh.rotation.y -= 0.04; mesh.rotation.x += 0.03; renderer.render({ scene, camera }); } } ``` -------------------------------- ### Install @color4bg/react with npm Source: https://github.com/winterx/color4bg.js/blob/main/packages/react/README.md Use npm to install the React package. This package requires React 16.8.0 or higher. ```bash npm install @color4bg/react ``` -------------------------------- ### React Integration Source: https://github.com/winterx/color4bg.js/blob/main/README.md Installation and usage of the React component wrapper. ```bash npm install @color4bg/react ``` ```jsx import { Color4Bg } from '@color4bg/react' function App() { return (
Beautiful WebGL background
Section content...