02 Drawing shapes with math
smoothstep: a soft switch
Turns a hard edge into a soft transition.
0.20.8
0.010.4
ExerciseTune values
Make this narrow transition on the right
Runs once per pixelDrag numbers, or edit the code
JS side
smoothstep(a, b, x) goes smoothly from 0 to 1 between a and b. It requires a < b.
Try it
- Make the width as small as possible: almost a step
- Make the width as large as possible: the transition fills the canvas