On Mon, Nov 16, 2009 at 4:51 PM, Kartik Thakore <thakore.kar...@gmail.com>wrote:

> How do I update this?  like animation?
>
> while(1)
> {
>
>   $pdl_memory->get_dataref();
>
> }
>

Yeah, you know, I used a terrible variable name for that piddle.  Let's try
this:

--------%<--------

use PDL;
use PDL::NiceSlice;

# Allocate a 10x10 array for rgb.  I think that only the zeroes function
allows
# you to declare a piddle with a specific data type
my $pdl = zeroes(byte, 3, 10, 10);

# Set values. Use in place to be sure we don't get another allocation, which
may be the wrong type.
# Note that the sequence wraps back to zero after hitting 256, because
they're bytes!
$pdl->inplace->sequence;

# Now for a really silly animation - turn all the pixels white
for (my $i = 0; $i < 300; $i++) {
  $pdl()->clump(-1)->($i) = 255;
  # Do something with piddle data here.
}

--------%<--------

Is that a bit clearer?  Does anybody have a better sample?

David

Reply via email to