isset( $c['family'] ) && in_array( $c['family'], array( 'triangles', 'steps', 'diagonal', 'curves', 'waves' ), true ) ? $c['family'] : 'triangles', 'seed' => sflo_number( $c['seed'] ?? null, 21873, 1, 2147483646 ), 'count' => sflo_number( $c['count'] ?? null, 7, 2, 16 ), 'amplitude' => sflo_number( $c['amplitude'] ?? null, 32, 0, 60 ), 'layers' => sflo_number( $c['layers'] ?? null, 1, 1, 3 ), 'upper' => sflo_color( $c['upper'] ?? null, '#f0f4f8' ), 'lower' => sflo_color( $c['lower'] ?? null, '#263b53' ), 'desktop' => sflo_number( $c['desktop'] ?? null, 112, 16, 300 ), 'tablet' => sflo_number( $c['tablet'] ?? null, 84, 16, 220 ), 'mobile' => sflo_number( $c['mobile'] ?? null, 56, 12, 160 ), 'flip' => ( $c['flip'] ?? null ) === true, 'motion' => ( $c['motion'] ?? null ) === true, ); } function sflo_fmt( $value ) { $result = rtrim( rtrim( number_format( $value, 3, '.', '' ), '0' ), '.' ); return $result === '-0' ? '0' : $result; } function sflo_geometry( $input ) { $c = sflo_normalize( $input ); $state = $c['seed']; $rand = static function () use ( &$state ) { $state = ( $state * 16807 ) % 2147483647; return ( $state - 1 ) / 2147483646; }; $a = $c['amplitude']; $n = $c['count']; $points = array(); $d = ''; $phase = $rand() * M_PI * 2; if ( $c['family'] === 'triangles' ) { $points[] = array( 0, 62 ); for ( $i = 0; $i < $n; $i++ ) { $points[] = array( ( $i + 0.25 + $rand() * 0.5 ) * 1200 / $n, 62 - $a * ( 0.25 + $rand() * 0.65 ) ); $points[] = array( ( $i + 1 ) * 1200 / $n, 62 + $a * $rand() * 0.2 ); } } elseif ( $c['family'] === 'steps' ) { $d = 'M0 ' . sflo_fmt( 55 + ( $rand() - 0.5 ) * $a ); for ( $i = 1; $i <= $n; $i++ ) { $d .= 'H' . sflo_fmt( $i * 1200 / $n ); if ( $i < $n ) { $d .= 'V' . sflo_fmt( 55 + ( $rand() - 0.5 ) * $a ); } } } elseif ( $c['family'] === 'diagonal' ) { $direction = $rand() > 0.5 ? 1 : -1; for ( $i = 0; $i <= $n; $i++ ) { $points[] = array( $i * 1200 / $n, 55 + $direction * ( $i / $n - 0.5 ) * $a + ( $rand() - 0.5 ) * $a * 0.3 ); } } else { $segments = $c['family'] === 'waves' ? $n * 2 : $n; for ( $i = 0; $i <= $segments; $i++ ) { $y = $c['family'] === 'waves' ? 55 + sin( $i / $segments * M_PI * $n + $phase ) * $a * 0.38 : 55 + ( $rand() - 0.5 ) * $a; $points[] = array( $i * 1200 / $segments, $y ); } $d = 'M' . sflo_fmt( $points[0][0] ) . ' ' . sflo_fmt( $points[0][1] ); $length = count( $points ); for ( $i = 0; $i < $length - 1; $i++ ) { $p0 = $points[ max( 0, $i - 1 ) ]; $p1 = $points[$i]; $p2 = $points[$i + 1]; $p3 = $points[ min( $length - 1, $i + 2 ) ]; $d .= 'C' . sflo_fmt( $p1[0] + ( $p2[0] - $p0[0] ) / 6 ) . ' ' . sflo_fmt( $p1[1] + ( $p2[1] - $p0[1] ) / 6 ) . ' ' . sflo_fmt( $p2[0] - ( $p3[0] - $p1[0] ) / 6 ) . ' ' . sflo_fmt( $p2[1] - ( $p3[1] - $p1[1] ) / 6 ) . ' ' . sflo_fmt( $p2[0] ) . ' ' . sflo_fmt( $p2[1] ); } } if ( $d === '' ) { foreach ( $points as $i => $p ) { $d .= ( $i ? 'L' : 'M' ) . sflo_fmt( $p[0] ) . ' ' . sflo_fmt( $p[1] ); } } $d .= 'L1200 140L0 140Z'; $paths = array(); for ( $i = 0; $i < $c['layers']; $i++ ) { $paths[] = array( 'd' => $d, 'offset' => -( $c['layers'] - 1 - $i ) * 7, 'opacity' => $i === $c['layers'] - 1 ? 1 : 0.22 + $i * 0.25 ); } return array( 'config' => $c, 'paths' => $paths, 'hidden' => $c['upper'] === $c['lower'] ); } function sflo_svg( $input ) { $g = sflo_geometry( $input ); $c = $g['config']; if ( $g['hidden'] ) { return ''; } $svg = ''; }