Coder Social home page Coder Social logo

Comments (8)

ShaMan123 avatar ShaMan123 commented on June 1, 2024 1

Image filters take an image source, canvas is an image source.
So you can use canvas .getElement() as if it were an image and filter it.

from fabric.js.

ShaMan123 avatar ShaMan123 commented on June 1, 2024

Try using the after:render canvas hook to do that
You can use the image filter logic

from fabric.js.

shashank-brightness avatar shashank-brightness commented on June 1, 2024

Can you please share how image filter thing would be using after:render? i am not familiar with that.

from fabric.js.

shashank-brightness avatar shashank-brightness commented on June 1, 2024

I am not getting your last comment and I searched but could not found the example so would you mind sharing the actual code please? I am looking for example using fabric js way in webgl.

from fabric.js.

asturur avatar asturur commented on June 1, 2024

To be clear your description is very confusing and is unclear what you want to achieve.
FabricJS does not support filters on objects different than images ( even if a pr for that exists and at some point it will be integrated ).

Is unclear if you want to apply that dynamically or just on some kind of export and what kind of performances do you expect.
For objects that mutate quickly uploading the pixels to the gpu is slow so performances aren't great.

The first thing you can do is clone your objects as image and filter then the images.

If you want to apply the filter to the canvas surface you have to do some kind of more elaborate hack involving a proxy fabricImage and an after:render event and some more stuff. Not going to explain that if i m not sure that is what you look for

from fabric.js.

shashank-brightness avatar shashank-brightness commented on June 1, 2024

@asturur
i have some sliders and i need to adjust brightness/contrast upon users changing that slider value but i don't want to export whole image via some function like toDataUrl() and apply filter on that exported image.

I have already read this thing but not sure if something better exists than this.
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter

I need filter for whole canvas. I can't better explain than this.

Also, let's say if object is something else(text) other than the image, it should be that only after applying filter and not image. So iterating over everything and adding them back as image and apply filter is too long and would not work as well.

Let me know if fabric js can change like that for whole canvas if something is available on fabric's native code.

from fabric.js.

shashank-brightness avatar shashank-brightness commented on June 1, 2024

@asturur
I need something like this which applies filter to everything below it (even to the background itself).
Screenshot 2024-03-21 151637

from fabric.js.

asturur avatar asturur commented on June 1, 2024

Provide me a jsfiddle or a codesandbox ( that works ) with a simple canvas and a rect and a text and i ll see if i can make an example

from fabric.js.

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.