-
Notifications
You must be signed in to change notification settings - Fork 17
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
Try SVG-based duotone filter #88
Conversation
This is really cool. I'm impressed you managed to build this as a plugin. One challenge, though — the filter should ideally be attached to only the element that is to receive the filter. In the case of the Image block, it's the In the case of the Cover block it's a bit more tricky as it's the block itself that holds the background image, i.e. the filter will affect child blocks also. We could potentially start with the Image block and then refactor the cover block to be more amenable to this type of filtering. I managed to fix that extra padding around the image, that was curious indeed and to be quite honest I'm not sure why my fix works. I created https://codepen.io/joen/pen/RwWxZpN?editors=1100 to debug this — it appears the Again, I don't know why this works, but it appears to. |
I think I know why your fix worked. I thought it would be okay to set the alpha to a constant The special values I had in the rows above are weighted values for producing a more natural looking grayscale instead of just taking the average of the values. They're the values for calculating luminance when converting to a YUV color space https://www.mathworks.com/help/matlab/ref/rgb2gray.html#algorithms |
Too awesome, feel free to restore your weighted values! I did not mean to overwrite your work, so absolutely go with the better values if you hvae the larger matte worked out. |
ccfe04e
to
366df38
Compare
366df38
to
a2e50b2
Compare
The block filter approach can only apply duotone to an entire block at a time, so I'll be opening another PR with a standalone block with only the image part filtered |
@jasmussen This is what I was able to get done today. It's still very broken, but I found a way to get the server-side rendering mostly working.
The ids are a little wonky, the filter is applied to the placeholder, it bleeds outside of the image in Chrome, it doesn't render at all in Firefox, and there isn't a way to disable them at the moment. But there are duotone filters and you can change the color of them. 🙂
There's a lot of other effects that can be done and this technique could be applied to any block. Going the SVG filter route also opens up the possibility of tweaking things like gamma and contrast on the duotone and adding more colors to the gradient.
Related to #12 and #13