Neurite icon indicating copy to clipboard operation
Neurite copied to clipboard

Flickering between Mandelbrot recalculation.

Open satellitecomponent opened this issue 1 year ago • 0 comments

One of @Paul-31415's fascinating contributions to Neurite is the ability for the fractal rendering to fully recalculate the svg positions at moments when a full refresh of the view is necessary. This is a significant reason why one can zoom so far into Neurite and could perhaps always have potential for both creative and/or obvious further iterations.

The relevant code is found in mandelbrot.js

Here is a snippet.

function recalc_svg(oldSVGpan,oldSVGzoom) {
    let node = svg_bg;
    for (let c of node.children){
        let path = c.getAttribute("d");
        let parts = path.split(/[, ]+/g);
        let coord = 0;
        let r = [];
        for (let p of parts){
            if (p.length && !isNaN(Number(p))){
                let c = coord?'y':'x';
                p = Number(p)/oldSVGzoom + oldSVGpan[c];
                p = (p-SVGpan[c])*SVGzoom;
                coord = 1-coord;
            }
            r.push(p);
        }
        c.setAttribute("d",r.join(" "));
        c.setAttribute("stroke-width",c.getAttribute("stroke-width")*SVGzoom/oldSVGzoom);
    }
}

This area of the code is the most directly relevant but is also not the full picture.

The current version of the recalculation is vastly improved from its initial

// TODO

however, one issue is a flickering where it appears the view is rotated for a frame before correctly restoring.

This is an issue which may not even be that hard to fix compared to what we have tackled so far, but is an area of the code I wanted to point out, as it is an entry-point into thinking about how the fractal rendering methods could be further expanded upon.

satellitecomponent avatar Feb 07 '24 04:02 satellitecomponent