Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flickering between Mandelbrot recalculation. #40

Open
satellitecomponent opened this issue Feb 7, 2024 · 1 comment
Open

Flickering between Mandelbrot recalculation. #40

satellitecomponent opened this issue Feb 7, 2024 · 1 comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested

Comments

@satellitecomponent
Copy link
Owner

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 satellitecomponent added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers question Further information is requested labels Feb 7, 2024
@Kvothe045
Copy link

@satellitecomponent requestAnimationFrame function might be able to solve the issue. Ensuring the update happens just before the next screen refresh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants