Giter Site home page Giter Site logo

GIF almost empty about jsgif HOT 4 OPEN

antimatter15 avatar antimatter15 commented on July 4, 2024
GIF almost empty

from jsgif.

Comments (4)

dronkit avatar dronkit commented on July 4, 2024

OK, sorry, no, that doesn't work either.
This is the issue:
I load a svg into the ctx canvas.

//load planet image
planet.ready = false;
planet.image = new Image();
planet.image.onload = function () {
planet.ready = true;
};

This is the code that initializes the drawing and draws the image into the canvas

//draw planet
    if (planet.ready)
    {
        ctx.drawImage(planet.image, planet.x-planet.r, planet.y-planet.r,planet.r*2,planet.r*2);
    }
    else
    {
    alert('Image not loaded');
    ctx.arc(planet.x,planet.y,planet.r,0,Math.PI*2);
    ctx.fill();
    }
    //trajectory drawing start
    ctx.strokeStyle="#FF0000";
    ctx.beginPath();
    ctx.moveTo(satellite.x,satellite.y);

At first my program doesn't load it I don't know why, so the svg isnt loaded into the canvas and the circle is drawn instead. In that case the gif recording works fine.
After a second if I hit my "reset" button the svg is loaded and everything is redrawn, with svg into the canvas. Then the gif recording fails.

Already tested and the issue isn't with the transformations or the lack of setSize.

from jsgif.

dronkit avatar dronkit commented on July 4, 2024

Aaaand... I got the workoround and the possible problem. The scripts and the SVG are in a folder in the local disk. If you try to do a getImage on a canvas that has an image from a different domain, Chrome gives security error. Also, all local files (file://) are treated as external, so, getImage has that error. Jsgif has a getImage for the passed canvas context and is probably hitting that error. Problem is the whole procedure is in a try-catch block so we don't get to know what's going on.
A workaround is to run chrome.exe --allow-file-access-from-files

from jsgif.

mpohl100 avatar mpohl100 commented on July 4, 2024

Maybe my pull request might be worth a try.
#34

By default the sampling factor is 10 which means not all pixels serve as input for the neural net in NeuQuant.js. This way pixel colours can be lost. Setting it to 1 will ensure that the network is learning from every pixel

from jsgif.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.