Electric Logo
HTML5 Canvas procedural lightning generator that traces jittered high-voltage arcs around an orbital emblem with live voltage, turbulence, and glow controls.
#canvas#lightning#glow#emblem
Customize
#A855F7
#FF9FFC
75%
1.4x
2
Installation
$pnpm dlx yourbrand@latest add @yourbrand/ElectricLogo-TS-TWUsage (synced with live props)
<ElectricLogo
color="#A855F7"
secondaryColor="#FF9FFC"
intensity={75}
speed={1.4}
rings={2}
/>Source Code
ElectricLogo.tsx"use client";
import React from "react";
export interface ElectricLogoProps {
color?: string;
secondaryColor?: string;
intensity?: number;
speed?: number;
rings?: number;
}
export function ElectricLogo({
color = "#A855F7",
secondaryColor = "#FF9FFC",
intensity = 75,
speed = 1.4,
rings = 2,
}: ElectricLogoProps) {
const canvasRef = React.useRef<HTMLCanvasElement | null>(null);
React.useEffect(() => {
const canvas = canvasRef.current;
if (!canvas) return;
const ctx = canvas.getContext("2d");
if (!ctx) return;
let raf = 0;
const render = (t: number) => {
const { width, height } = canvas;
ctx.clearRect(0, 0, width, height);
const cx = width / 2;
const cy = height / 2;
const r = Math.min(width, height) * 0.3;
for (let layer = 0; layer < rings; layer += 1) {
ctx.beginPath();
for (let a = 0; a <= 72; a += 1) {
const theta = (a / 72) * Math.PI * 2;
const jitter = Math.sin(theta * 9 + t * 0.008 * speed + layer * 2.1) * (intensity * 0.09);
const x = cx + Math.cos(theta) * (r + jitter);
const y = cy + Math.sin(theta) * (r + jitter);
if (a === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
}
ctx.strokeStyle = layer % 2 === 0 ? color : secondaryColor;
ctx.shadowColor = color;
ctx.shadowBlur = 18;
ctx.lineWidth = 2;
ctx.stroke();
}
raf = requestAnimationFrame(render);
};
raf = requestAnimationFrame(render);
return () => cancelAnimationFrame(raf);
}, [color, secondaryColor, intensity, speed, rings]);
return <canvas ref={canvasRef} width={360} height={240} className="h-full w-full" />;
}
Props API
| Prop | Type | Default | Description |
|---|---|---|---|
| color | string (hex) | "#A855F7" | Primary electric plasma hue. |
| secondaryColor | string (hex) | "#FF9FFC" | Outer corona glow color. |
| intensity | number | 75 | Bolt displacement turbulence. |
| speed | number | 1.4 | Arc regeneration speed. |
| rings | number | 2 | Number of concurrent plasma rings. |