#!/usr/bin/perl # Translate b&w or color bsd files into raw rgb bytes # Apply additive, multiplicative and exponential factors @d[0 .. 24*60*3-1] = 0; &parse(); print pack('C*', @d); sub parse { while(<>) { ($h,$m,$s) = /(\d+)\:(\d+)\:(\d+)/; $t = ($h * 60 + $m) * 3; if (($r,$g,$b) = /=(\S+) =(\S+) =(\S+)/) { $d[$t+0] = &scale ($r, 0, 300, 25); $d[$t+1] = &scale ($g, 0, 320, 25); $d[$t+2] = &scale ($b, 0, 310, 25); } else { ($d) = /=(\S+)/; $d[$t] = $d[$t+1] = $d[$t+2] = &scale ($d, 0, 300, 25); } } } sub scale { local ($_,$a,$m,$e)=@_; local ($n,$d) = /(\d+)\/(\d+)/; $x=1/($n/$d+$a); $x=int(log($x)*$e+$m); return $x > 255 ? 255 : ($x < 0 ? 0 : $x); }