-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
chore(TS): filters #8474
chore(TS): filters #8474
Conversation
Build Stats
|
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.
🤢
I added fromObject
on each filter
1, | ||
]; | ||
}, | ||
createTexture(backend: WebGLFilterBackend, image: Image) { |
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.
inferred
type: 'Blur', | ||
|
||
/* | ||
'gl_FragColor = vec4(0.0);', |
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.
what is this?
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.
i don't remember. either a different blur or a more performant version of the same blur
|
||
mainParameter: 'matrix', | ||
setOptions({ matrix, ...options }: Record<string, any>) { |
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.
I don't like this but until default values are settled this seems the best option
* @param {Number} options.passes The number of filters remaining to be applied. | ||
*/ | ||
applyTo(options: TWebGLPipelineState | T2DPipelineState) { | ||
if (isWebGLPipelineState(options)) { |
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.
this is a change supposedly
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.
i think is fine. the code before was adding a useless passes property to the 2d pipeline.
})(typeof exports !== 'undefined' ? exports : window); | ||
((object.subFilters || []) as AbstractBaseFilter[]).map((filter) => | ||
Object.values(filters) | ||
.find((klass) => klass.prototype?.type === filter.type)! |
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.
some ugly hack since type is not static
I/O registry will handle it
*/ | ||
type: 'Gamma', | ||
gamma: GammaInput; | ||
rgbValues?: { |
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.
breaking change supposedly but not really since it is private
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.
ready
Yes filters should be standalone and will be probably soon, this in an export only issue and we can fix that easily. |
fragmentSource: { | ||
multiply: 'gl_FragColor.rgb *= uColor.rgb;\n', | ||
screen: | ||
'gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n', | ||
add: 'gl_FragColor.rgb += uColor.rgb;\n', | ||
diff: 'gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n', | ||
subtract: 'gl_FragColor.rgb -= uColor.rgb;\n', | ||
lighten: 'gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n', | ||
darken: 'gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n', | ||
exclusion: | ||
'gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n', | ||
overlay: ` | ||
if (uColor.r < 0.5) { | ||
gl_FragColor.r *= 2.0 * uColor.r; | ||
} else { | ||
gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r); | ||
} | ||
if (uColor.g < 0.5) { | ||
gl_FragColor.g *= 2.0 * uColor.g; | ||
} else { | ||
gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g); | ||
} | ||
if (uColor.b < 0.5) { | ||
gl_FragColor.b *= 2.0 * uColor.b; | ||
} else { | ||
gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b); | ||
} | ||
`, | ||
tint: ` | ||
gl_FragColor.rgb *= (1.0 - uColor.a); | ||
gl_FragColor.rgb += uColor.rgb; | ||
`, | ||
}, | ||
}; |
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.
this can probably be a const outside the default definition. I can move it
export * from './base_filter.class'; | ||
export * from './blendcolor_filter.class'; | ||
export * from './blendimage_filter.class'; | ||
export * from './blur_filter.class'; | ||
export * from './brightness_filter.class'; | ||
export * from './colormatrix_filter.class'; | ||
export * from './composed_filter.class'; | ||
export * from './contrast_filter.class'; | ||
export * from './convolute_filter.class'; | ||
export * from './filter_generator'; | ||
export * from './gamma_filter.class'; | ||
export * from './grayscale_filter.class'; | ||
export * from './hue_rotation.class'; | ||
export * from './invert_filter.class'; | ||
export * from './noise_filter.class'; | ||
export * from './pixelate_filter.class'; | ||
export * from './removecolor_filter.class'; | ||
export * from './resize_filter.class'; | ||
export * from './saturate_filter.class'; | ||
export * from './vibrance_filter.class'; |
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.
in general i would like to avoid barrel imports.
The reason for me is that they don't give me anything and they mask to me where the file is and what name it has.
For now it does not matter since this is still needeed for the bundle i suppose
Oh was it a TS problem or something else? |
Motivation
Description
This PR took a lot more time than I intended for it
Changes
IMO filters should not reside on Image, they should be standalone
Gist
In Action