help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
star-pattern-maker
/
js
RSK World
star-pattern-maker
Star Pattern Maker - HTML5 Canvas + 3D Rendering + Physics Simulation + AI Patterns + Generative Audio + Modern UI + Glassmorphism Design
js
  • 3d-engine.js3.8 KB
  • ai-patterns.js5.6 KB
  • animations.js1.4 KB
  • audio.js1.3 KB
  • controls.js12.2 KB
  • export.js3.9 KB
  • filters.js3.5 KB
  • fractals.js3.5 KB
  • gallery.js2.5 KB
  • main.js1.9 KB
  • particles.js1.4 KB
  • physics.js1.7 KB
  • presets.js2.8 KB
  • randomizer.js1.4 KB
  • renderer.js7 KB
  • shaders.js6.5 KB
  • shapes.js1.7 KB
  • sound-gen.js4.4 KB
  • state.js1.9 KB
  • symmetry.js3.9 KB
  • themes.js1.4 KB
  • timeline.js4.2 KB
  • utils.js546 B
state.jsshaders.js
js/state.js
Raw Download
Find: Go to:
/* V7 State Manager */
export const state = {
    // Geometry
    spikes: 5,
    outerRadius: 150,
    innerRadius: 75,
    curve: 0,
    twist: 0,
    lineWidth: 5,

    // Effects
    glow: 0,
    jitter: 0,
    speed: 0,
    rotation: 0,

    // Modes
    wallpaperMode: false,
    cols: 3,
    rows: 3,

    kaleidoscopeMode: false,
    segments: 6,

    audioMode: false,

    // V8 Unique Features
    pulseEnabled: false,
    pulseSpeed: 5,
    rainbowMode: false,
    parallaxEnabled: false,
    mouseX: 0,
    mouseY: 0,

    // V9 Expansion
    fractalMode: false,
    fractalDepth: 2,

    // V11 Visual FX
    trailEnabled: false,
    trailStrength: 0.1,
    echoEnabled: false,
    echoCount: 3,

    // V12 Quantum Effects
    gravityEnabled: false,
    orbitEnabled: false,
    chromaticAberration: false,
    holographicMode: false,

    // V13 Neural Canvas
    glitchEnabled: false,
    scanlinesEnabled: false,
    vignetteEnabled: false,
    bloomEnabled: false,
    pixelateEnabled: false,
    invertEnabled: false,
    morphEnabled: false,
    colorShiftEnabled: false,
    mandalaMode: false,
    spiralMode: false,
    tessellationMode: false,
    mirrorMode: false,

    // V14 Quantum Nexus
    depthFieldEnabled: false,
    warpFieldEnabled: false,
    chromaticAberrationV2: false,
    edgeGlowEnabled: false,
    waveDistortEnabled: false,
    colorGradingEnabled: false,
    neuralPatternMode: false,
    lSystemMode: false,
    voronoiMode: false,
    timelineEnabled: false,

    // Particles (New)
    particlesEnabled: true,

    // Colors
    fillColor: '#6366f1',
    fillColor2: '#ec4899',
    useGradient: true,
    strokeColor: '#ffffff',
    bgColor: '#000000',

    // Internal
    _gradId: null
};

// Simple Observer Pattern for reactivity if needed,
// but for now we just export the object.
// UI updates State, Renderer reads State.
94 lines•1.9 KB
javascript
js/shaders.js
Raw Download
Find: Go to:
/* V14 Shaders Module - Advanced Shader-like Effects */
import { state } from './state.js';

/**
 * Apply all enabled shader effects
 */
export function applyShaderEffects(ctx, canvas) {
    if (state.depthFieldEnabled) {
        applyDepthField(ctx, canvas);
    }

    if (state.warpFieldEnabled) {
        applyWarpField(ctx, canvas);
    }

    if (state.chromaticAberrationV2) {
        applyChromaticAberration(ctx, canvas);
    }

    if (state.edgeGlowEnabled) {
        applyEdgeGlow(ctx, canvas);
    }

    if (state.waveDistortEnabled) {
        applyWaveDistortion(ctx, canvas);
    }

    if (state.colorGradingEnabled) {
        applyColorGrading(ctx, canvas);
    }
}

/**
 * Depth Field - Simulated depth of field blur
 */
function applyDepthField(ctx, canvas) {
    const cx = canvas.width / 2;
    const cy = canvas.height / 2;
    const maxDist = Math.sqrt(cx * cx + cy * cy);

    // Simple radial blur simulation
    ctx.save();
    ctx.globalCompositeOperation = 'multiply';

    const gradient = ctx.createRadialGradient(cx, cy, 0, cx, cy, maxDist);
    gradient.addColorStop(0, 'rgba(255,255,255,1)');
    gradient.addColorStop(0.5, 'rgba(255,255,255,0.9)');
    gradient.addColorStop(1, 'rgba(200,200,200,0.7)');

    ctx.fillStyle = gradient;
    ctx.fillRect(0, 0, canvas.width, canvas.height);
    ctx.restore();
}

/**
 * Warp Field - Space-time distortion
 */
function applyWarpField(ctx, canvas) {
    const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    const data = imageData.data;
    const tempCanvas = document.createElement('canvas');
    tempCanvas.width = canvas.width;
    tempCanvas.height = canvas.height;
    const tempCtx = tempCanvas.getContext('2d');
    tempCtx.putImageData(imageData, 0, 0);

    ctx.clearRect(0, 0, canvas.width, canvas.height);

    const cx = canvas.width / 2;
    const cy = canvas.height / 2;
    const strength = 30;

    for (let y = 0; y < canvas.height; y += 2) {
        for (let x = 0; x < canvas.width; x += 2) {
            const dx = x - cx;
            const dy = y - cy;
            const dist = Math.sqrt(dx * dx + dy * dy);
            const angle = Math.atan2(dy, dx);

            const warp = strength / (dist + 1);
            const newX = x + Math.cos(angle) * warp;
            const newY = y + Math.sin(angle) * warp;

            if (newX >= 0 && newX < canvas.width && newY >= 0 && newY < canvas.height) {
                const pixel = tempCtx.getImageData(newX, newY, 1, 1);
                ctx.putImageData(pixel, x, y);
            }
        }
    }
}

/**
 * Enhanced Chromatic Aberration
 */
function applyChromaticAberration(ctx, canvas) {
    const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    const data = imageData.data;
    const offset = 5;

    // Shift channels
    for (let i = 0; i < data.length; i += 4) {
        const rIdx = i + offset * 4;
        const bIdx = i - offset * 4;

        if (rIdx < data.length) {
            data[i] = data[rIdx]; // R from offset
        }
        if (bIdx >= 0) {
            data[i + 2] = data[bIdx + 2]; // B from -offset
        }
    }

    ctx.putImageData(imageData, 0, 0);
}

/**
 * Edge Glow - Neon edge detection
 */
function applyEdgeGlow(ctx, canvas) {
    const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    const data = imageData.data;
    const w = canvas.width;
    const h = canvas.height;

    // Simple edge detection (Sobel-like)
    const edges = new Uint8ClampedArray(data.length);

    for (let y = 1; y < h - 1; y++) {
        for (let x = 1; x < w - 1; x++) {
            const idx = (y * w + x) * 4;

            // Get surrounding pixels
            const tl = data[((y - 1) * w + (x - 1)) * 4];
            const tr = data[((y - 1) * w + (x + 1)) * 4];
            const bl = data[((y + 1) * w + (x - 1)) * 4];
            const br = data[((y + 1) * w + (x + 1)) * 4];

            const gx = (tr + 2 * data[((y) * w + (x + 1)) * 4] + br) -
                (tl + 2 * data[((y) * w + (x - 1)) * 4] + bl);
            const gy = (bl + 2 * data[((y + 1) * w + x) * 4] + br) -
                (tl + 2 * data[((y - 1) * w + x) * 4] + tr);

            const edge = Math.sqrt(gx * gx + gy * gy);

            if (edge > 50) {
                edges[idx] = 255;     // R
                edges[idx + 1] = 255; // G
                edges[idx + 2] = 255; // B
                edges[idx + 3] = 255; // A
            }
        }
    }

    // Overlay edges with glow
    ctx.save();
    ctx.globalCompositeOperation = 'screen';
    ctx.filter = 'blur(3px)';
    const edgeData = new ImageData(edges, w, h);
    ctx.putImageData(edgeData, 0, 0);
    ctx.filter = 'none';
    ctx.restore();
}

/**
 * Wave Distortion - Sine wave displacement
 */
function applyWaveDistortion(ctx, canvas) {
    const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    const tempCanvas = document.createElement('canvas');
    tempCanvas.width = canvas.width;
    tempCanvas.height = canvas.height;
    const tempCtx = tempCanvas.getContext('2d');
    tempCtx.putImageData(imageData, 0, 0);

    ctx.clearRect(0, 0, canvas.width, canvas.height);

    const amplitude = 10;
    const frequency = 0.05;
    const time = Date.now() * 0.001;

    for (let y = 0; y < canvas.height; y++) {
        const offset = Math.sin(y * frequency + time) * amplitude;
        ctx.drawImage(tempCanvas, offset, y, canvas.width, 1, 0, y, canvas.width, 1);
    }
}

/**
 * Color Grading - Professional color correction
 */
function applyColorGrading(ctx, canvas) {
    const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    const data = imageData.data;

    // Cinematic color grading (teal and orange)
    for (let i = 0; i < data.length; i += 4) {
        const r = data[i];
        const g = data[i + 1];
        const b = data[i + 2];

        // Boost oranges in highlights
        if (r > 128) {
            data[i] = Math.min(255, r * 1.1);
            data[i + 1] = Math.min(255, g * 0.95);
        }

        // Boost teals in shadows
        if (b > 100 && r < 128) {
            data[i + 1] = Math.min(255, g * 1.05);
            data[i + 2] = Math.min(255, b * 1.1);
        }

        // Increase contrast
        data[i] = ((data[i] - 128) * 1.2) + 128;
        data[i + 1] = ((data[i + 1] - 128) * 1.2) + 128;
        data[i + 2] = ((data[i + 2] - 128) * 1.2) + 128;
    }

    ctx.putImageData(imageData, 0, 0);
}
220 lines•6.5 KB
javascript

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer