Coder Social home page Coder Social logo

Resetting of Filtrr about filtrr HOT 12 CLOSED

alexmic avatar alexmic commented on August 11, 2024
Resetting of Filtrr

from filtrr.

Comments (12)

alexmic avatar alexmic commented on August 11, 2024

Hey Ian, thanks for this. I will work on it soon.

from filtrr.

alexmic avatar alexmic commented on August 11, 2024

Hey @iandevlin, I just pushed 0.5 which contains a reset() method. Does that work for you? I updated the readme documentation and created an example as well.

from filtrr.

iandevlin avatar iandevlin commented on August 11, 2024

Hi Alec, fast response! Many thanks for that! I won't be able to try it for a bit, but if you've tested it I suspect it works :-) I'll let you know of course. Thanks again.

from filtrr.

iandevlin avatar iandevlin commented on August 11, 2024

Hi Alec! Just had a chance to test it, works like a charm. Many thanks!

from filtrr.

iandevlin avatar iandevlin commented on August 11, 2024

Hmm, I spoke too soon. If I change the image in the canvas dynamically, the image in the filtrr2 still remains as the previous image.

from filtrr.

alexmic avatar alexmic commented on August 11, 2024

What do you mean dynamically? Can you give me some example code?

from filtrr.

iandevlin avatar iandevlin commented on August 11, 2024

Sorry, I should have been clear. I mean if I draw something to the canvas and apply a filter - all is well. If, while the same image is in the canvas and I apply a new filter (calling reset() beforehand) all works well.

But if I change the image in the canvas, call reset() and apply a filter, the filter is applied to the previous image that was in the canvas and not the new one.

from filtrr.

alexmic avatar alexmic commented on August 11, 2024

Hm, so this is happening because each Filtrr2 object is designed to work with the image that it is applied on. Internally it stores the canvas image data and writes it back on render(). When you change the image, the image data do not change hence you get the old image. reset() just sets the image data to a "clean" copy of the original image. The Filtrr2 constructor also caches instances and returns the same one for the same selector.

from filtrr.

iandevlin avatar iandevlin commented on August 11, 2024

Yeah, I understand why it's happening but it's not what I need I'm afraid. Any chance of adding a boolean to the reset() function, which when true, also clears the image cache? Default would of course be false.

from filtrr.

alexmic avatar alexmic commented on August 11, 2024

Yeah that's not a bad idea - either that or add a new method reinit() or something so that it's more explicit. I will work on it as soon as I find some free time.

from filtrr.

iandevlin avatar iandevlin commented on August 11, 2024

Sounds like a plan, and thanks again for the speedy feedback.

from filtrr.

alexmic avatar alexmic commented on August 11, 2024

Hey @iandevlin,

Sorry for taking ages to fix this.

I've just pushed a fix that allows options to be passed in the constructor. The only option available for now is 'store'. Setting it to false will allow you to create new Filtrr2 instances on the same elements, hence once you change the canvas image you can actually create a new instance to override your previous one. Remember to use store=false for all your instances if this is a comming occurence, for example:

var f = Filtrr2("#id", function() {..}, {
    store: false
 });

from filtrr.

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.