Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

From terminal output to avi - "let's go to the movies" explained

by teamster_jr (Curate)
on Apr 12, 2006 at 10:02 UTC ( [id://542789]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # s#((?{$a.=$+})\s?(\S*)\s?)*#$a=~s/Z/ /g;$a#see
    
  2. or download this
    ( $width, $height ) = split /x/, shift || "19x20";
    
  3. or download this
    $x_max = 10 + 10 * $width;
    $y_max = 20 + 10 * $height;
    
  4. or download this
    @m = ( ( 31, (15) x ( $width - 1 ) ) x $height, (31) x $width );
    
  5. or download this
    #    8
    #  1   2
    ...
    
    #  v u d r l
    #  1 1 1 1 1
    
  6. or download this
    $m[$c] |= 16,
    
  7. or download this
    !(
    
  8. or download this
    @a = grep !( $m[ $c + $$_[0] ] & 16 + $| * $$_[1] ),
    #left
    ...
    # down
      [ -$width, 2 ]
      )
    
  9. or download this
    ? $c = pop @p :
    
  10. or download this
    ${
          ( $i, $j ) = @{ $a[ rand @a ] };
    
  11. or download this
          $m[$c] &= ~ (8 / $j);
    
  12. or download this
          push @p, $c;
    
  13. or download this
          $m[ $c += $i ] &= ~$j;
    
  14. or download this
          ++$counter - $height * $width + $height ||
            map $_ &= 15, @m, splice(@p), $c = $| = 1
      }
    
  15. or download this
    #print"\ec",
    # map$_%9?($_-$c?$m[$_]&2?_:$":o).($m[$_]&8?"|":_):$/,1..72
    
  16. or download this
      until $| & $c + 2 > $width * $height;
    
  17. or download this
    $space = $x_max - 4 * int $x_max / 4;
    
  18. or download this
    $image_size = ( $x_max + $space ) * $y_max;
    
  19. or download this
    $image = pack "x" x ( ( $x_max + $space ) * $y_max );
    
  20. or download this
    sub line {
        my ( $x1, $x_len, $y1, $y2, $e ) = @_;
    
  21. or download this
        @a = sort { "000$a" <=> "000$b" } $y1, $y2 || $y1;
        for ( $a[0] .. $a[1] ) {
    
  22. or download this
            $s = ( $y_max - $_ ) * ( $x_max + $space ) + $x1;
            vec( $image, $_, 8 ) = $e || 2 for $s .. $s + $x_len - 1;
        }
    }
    
  23. or download this
    sub t { 
       $a = shift;
       $x = 10 * ( $a % $width ); 
       $y = 10 * ( 2 + int $a / $width ) 
    }
    
  24. or download this
    #  top 
    line 9, $x_max - 20, 10;
    ...
    line 9, 1, 10, $y_max - 10;
    #  right 
    line $x_max- 11, 1, 10, $y_max - 10;
    
  25. or download this
    map {
    
  26. or download this
       t $_;
    
  27. or download this
        if ( $_ % $width ) {
    
  28. or download this
            $m[$_] & 2 ? line $x - 1, 11, $y : "";
    
  29. or download this
            $m[$_] & 8 ? line $x + 9, 1, $y - 10, $y : "";
        }
    
  30. or download this
    } 0 .. -1 + $width * $height;
    
  31. or download this
    open( FH, ">al.avi" );
    binmode FH;
    select FH;
    # a space saver
    $LIST = "LIST";
    
  32. or download this
    print pack "V*", /\d/ ? $_ : unpack "V*", $_ for
    
  33. or download this
       "RIFF",
          # length of file (header length + data length + index length)
    ...
                # length of avi header:
                # (40) + length of color table (1024)
                1064,
    
  34. or download this
              
                    40,
                    $x_max,
    ...
                    0,
                    $image_size,
                   (0) x 4,
    
  35. or download this
                   pack( 
                         ( "H" x 1024 ), 
                         "f", "f", "f", 0, "a" 
                       ),
    
  36. or download this
    # "JUNK", 
    #   <length of junk to boundary>, 
    #   <null bytes to boundry>
    
  37. or download this
    $LIST,
    
  38. or download this
    ( 4 + ( $image_size + 8 ) * $num_frames ),
    "movi";
    
  39. or download this
    map {
    
  40. or download this
        print STDOUT ++$G, $/;
    
  41. or download this
        t $previous|| 1;
    
  42. or download this
        $left = $x;
    
  43. or download this
        $top = $y;
    
  44. or download this
        t $_;
        $right = $x;
    
  45. or download this
        if ( $left > $x ) { $right = $left; $left = $x }
    
  46. or download this
        line $left+ 2, 5 + $right - $left, 
        ( $top < $y ? $top : $y ) - 7,
        ( $top < $y ? $y : $top ) - 3,
    
  47. or download this
          1;
        $previous = $_;
    
  48. or download this
        print "00db" . pack( "V", $image_size ) . $image
    } @p, ( -1 + $width * $height ) x 3;
    
  49. or download this
    print "idx1" . pack "V", 16 * $num_frames;
    $o = 4;
    
  50. or download this
    for ( 1 .. $num_frames ) { print "00db" . pack "VVV", 16, $o, $image_s
    +ize; $o += $image_size + 8 }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://542789]
Approved by Old_Gray_Bear
Front-paged by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 22:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found