Skip to content

Instantly share code, notes, and snippets.

@buzztiaan
Created September 14, 2019 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buzztiaan/3957c50b2c96711eab5d909f6e6c3bbd to your computer and use it in GitHub Desktop.
Save buzztiaan/3957c50b2c96711eab5d909f6e6c3bbd to your computer and use it in GitHub Desktop.
pixelflut plasma for @NURDspace
#!/usr/bin/perl -w
use IO::Socket::INET;
use Time::HiRes qw( gettimeofday tv_interval usleep );
my $sock = new IO::Socket::INET(PeerAddr => '10.208.42.159',
PeerPort => 5003,
Proto => 'udp', Timeout => 1) or die('Error opening socket.');
my $x;
my $y;
my $starttime = [gettimeofday];
my $fakepi = 3.1415;
$x = 0;
while(1) {
while ($x < 128) {
$y = 0;
my $data = "";
while ($y < 32) {
# $t = tv_interval ( $starttime );
($seconds, $microseconds) = tv_interval ( $starttime );
$t = ($seconds*10);
$a = sin( ($y/13.37) + ($t / 16) ) *128 +
sin( ($x/25) + ($t / 32) ) *128 +
sin( ($y/5.5) + ($t / 15.2) ) * 128;
$b = sin( ($y/3) + ($t / 32) ) *128 +
sin( ($x/20) + ($t / 8) ) *128;
@colors = ($a % 256, (($a+$b)/2)%256, $b % 256);
# @colors = (0,0,0);
$color = sprintf("%02x%02x%02x", $colors[0], $colors[1], $colors[2]);
$data .= "PX $x $y $color\n";
$y++;
}
print $sock $data;
$x++;
}
$x = 0;
$y = 0;
usleep(25000);
}
@buzztiaan
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment