-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Added vibrance filter (for increasing saturation of muted colors) #7189
Conversation
Code Coverage Summary
|
Code Coverage Summary
|
* Constructor | ||
* @memberOf fabric.Image.filters.Vibrance.prototype | ||
* @param {Object} [options] Options object | ||
* @param {Number} [options.vibrance=0] Vibrance value for the image (between -1 and 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok is written here, but we can put this also over the vibrance property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Should we add a test? |
i can setup a test suite for all the filters maybe since you don't have examples. |
Code Coverage Summary
|
yeah, I guess we don't really have any visual tests for filters yet, do we |
Code Coverage Summary
|
Code Coverage Summary
|
@@ -15,7 +15,7 @@ | |||
* @see {@link http://fabricjs.com/image-filters|ImageFilters demo} | |||
* @example | |||
* var filter = new fabric.Image.filters.Saturation({ | |||
* saturation: 100 | |||
* saturation: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed this to 1 (100 makes no sense when the recommended range is -1 to 1)
* | ||
* @param {Number} saturation | ||
* @default | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a description to the variable saturation filter too since it was missing
I had this idea on my head for a bit: this code here: /**
* Return WebGL uniform locations for this filter's shader.
*
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
* @param {WebGLShaderProgram} program This filter's compiled shader program.
*/
getUniformLocations: function(gl, program) {
return {
uVibrance: gl.getUniformLocation(program, 'uVibrance'),
};
},
/**
* Send data from this filter to its shader program's uniforms.
*
* @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.
* @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects
*/
sendUniformData: function(gl, uniformLocations) {
gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);
}, is sort of repeated for each filter, but at the end is conceptually:
We still need a smart way to identify the type of the filter, in this case All the rest is wrapping code that could be in the base filter class. If not all, at least `getUniformLocation can be streamlined to a data declaration. |
Added a Vibrance filter for increasing the saturation of an image's more muted colors. Formula based on Caman.js
https://jsfiddle.net/melchiar/oq4eydrj/