Giter Site home page Giter Site logo

Comments (10)

deanm avatar deanm commented on July 20, 2024
                var palette2 = new Uint8Array( 32 * 3 );

Seems to work fine. From what I saw in my test your palette was 24 colors.

Sorry, I will try to clarify the code up a bit. There is two different aspects.

  1. GIF format enforces a palette of power of 2 (8, 16, 32, 64, etc) number of colors.
  2. omggif takes 3 arrays elements for each color in the palette [r, g, b, r, g, b, ...]. This could (and maybe should / will) be changed to [rgb, rgb, ...].

So for now really what you need is palette.length / 3 to be a power of 2. omggif checks for both of those things.

So what you really want is to pass omggif something like 64*3, 32 * 3, etc, since there are separate elements for RGB.

I just wrote this code today, now that you mention it I will probably change the palettes to be RGB together, it's a bit more convenient when you are writing things out by hand to (0xff78fa vs 0xff, 0x78, 0xfa) and it means less array elements which is probably not a bad thing.

Hope that helps

from omggif.

mrdoob avatar mrdoob commented on July 20, 2024

Oh damn. I was missing the * 3...

So now it kind of works:
https://gist.github.com/4582927

It shows the top half of the gif fine, the second half gets corrupted.

from omggif.

deanm avatar deanm commented on July 20, 2024

I have a look at it tomorrow, thanks for the code to reproduce

from omggif.

deanm avatar deanm commented on July 20, 2024

I think it should be fixed in 99faac4.

from omggif.

mrdoob avatar mrdoob commented on July 20, 2024

Cool! Works fine now :)

from omggif.

mrdoob avatar mrdoob commented on July 20, 2024

Some tests:

lines
cube

from omggif.

deanm avatar deanm commented on July 20, 2024

I just spent a few hours optimizing (yesterday I just wrote the naive initial implementation). There is about a 4x performance increase in the LZW compressor. It made the code slightly trickier, so let me know if you see any problems. I will spend a little bit more time looking at optimizations, although I've tried a few and I think I am pretty close to the balance of making the code very ugly for only helping a few percent.

PS: Thanks for the examples! It works! ; )

from omggif.

mrdoob avatar mrdoob commented on July 20, 2024

Wow. It's much faster compared to this morning. It's almost realtime now.
http://mrdoob.com/lab/javascript/omggif/

from omggif.

deanm avatar deanm commented on July 20, 2024

I just pushed another improvement of 15%, but it's getting to the manually unrolled/inlined point, so I think I'll call it good for now. Overall it's about 5x yesterday's code.

from omggif.

mrdoob avatar mrdoob commented on July 20, 2024

Impressed

from omggif.

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.