crosses
Rebuild the shader only when the prop crosses value, not on every change.
crosses(value: number): RecompileRule
Import crosses from shaders/std.
Put it on a prop's recompile:. Pair it with an identity rule at the same value: the rule decides whether the filter is skipped, and this is what lets that decision change.
Parameters
| Name | Type | Notes |
|---|---|---|
value | number |
Example
props: {shift: {default: 0, recompile: crosses(0)}},
effect: hueRotate(p('shift')),
identityWhen: isZero('shift'),
Tip. Without it a runtime prop never rebuilds, so a filter that started skipped stays skipped.
See also
isZero— Skip the filter entirely whilepropis exactly 0.isValue— Skip the filter entirely whilepropequalsvalue, for a filter whose no-op is not 0.recompileWhen— Rebuild when your own test of the old and new value says so, for a thresholdcrossescannot express.
Used by
BrightnessContrast, Exposure, FilmGrain, FilmStock, Glow, GradientMap, HueShift, MeshGradient, Repeater, Saturation, Sharpness, Solarize, Sparkle, Vibrance, Vignette, Watercolor