Skip to content

Instantly share code, notes, and snippets.

@windytan
Created January 23, 2019 12:08
Show Gist options
  • Save windytan/69710b7150b205cdb64450f3211206e7 to your computer and use it in GitHub Desktop.
Save windytan/69710b7150b205cdb64450f3211206e7 to your computer and use it in GitHub Desktop.
use warnings;
my $width = 1000;
my $height = 500;
my $n_pts = 1000;
my $wavelength = 9;
print '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" '.
'width="'.$width.'" height="'.$height.'">'."\n";
for my $n (0..$n_pts-1) {
$x1 += $f1;
$x2 += $f2;
$y1 = 200 + 50 * sin($x1 / $wavelength);
$y2 = 200 + 50 * sin($x2 / $wavelength + 1.5);
$f1 = abs($y1 - $y2) / 10;
$f2 = 1 - $f1;
print "<line x1='".($x1/250*$width)."' x2='".($x2/250*$width)."' ".
"y1='$y1' y2='$y2' style='stroke:#000000'/>\n";
}
print "</svg>\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment