@@ -71,29 +71,35 @@ export const LFO = forwardRef<LFORef, LFOProps>((props, ref) => {
7171 const svg = d3 . select ( LFORef . current ) . select ( 'svg' ) . attr ( 'width' , width ) . attr ( 'height' , height )
7272 svg . selectAll ( '*' ) . remove ( )
7373
74+ const data = d3 . range ( 0 , 4 * Math . PI * ( speed * 10 ) , 0.01 ) . map ( ( x ) => {
75+ return {
76+ x,
77+ y : Math . sin ( x ) * frequency * ( max - min ) * 0.5 + ( max + min ) / 2 ,
78+ }
79+ } )
80+
7481 if ( delay > 0 ) {
82+ svg
83+ . append ( 'circle' )
84+ . attr ( 'cx' , delay )
85+ . attr ( 'cy' , height / 2 )
86+ . attr ( 'r' , lineWidth / 2 )
87+ . attr ( 'fill' , lineColor )
88+
7589 svg
7690 . append ( 'line' )
7791 . attr ( 'x1' , 0 )
7892 . attr ( 'y1' , height / 2 )
79- . attr ( 'x2' , delay )
93+ . attr ( 'x2' , delay + 1 )
8094 . attr ( 'y2' , height / 2 )
8195 . attr ( 'stroke' , lineColor )
8296 . attr ( 'stroke-width' , lineWidth )
8397 }
8498
85- const data = d3 . range ( 0 , 4 * Math . PI * ( speed * 10 ) , 0.01 ) . map ( ( x ) => {
86- return {
87- x,
88- y : Math . sin ( x ) * frequency * ( max - min ) * 0.5 + ( max + min ) / 2 ,
89- }
90- } )
91-
9299 const line = d3
93100 . line < { x : number ; y : number } > ( )
94101 . x ( ( d ) => xScale . current ! ( d . x ) )
95102 . y ( ( d ) => yScale . current ! ( d . y ) )
96- . curve ( d3 . curveBasis )
97103
98104 svg
99105 . append ( 'path' )
@@ -102,8 +108,7 @@ export const LFO = forwardRef<LFORef, LFOProps>((props, ref) => {
102108 . attr ( 'stroke' , lineColor )
103109 . attr ( 'stroke-width' , lineWidth )
104110 . attr ( 'd' , line )
105- // -1 to fix the gap between the line and the delay line
106- . attr ( 'transform' , `translate(${ delay - 0.8 } , 0)` )
111+ . attr ( 'transform' , `translate(${ delay } , 0)` )
107112 }
108113
109114 const { base, svg } = useStyle ( )
0 commit comments