Graphics::Raylib::Texture - Drawable Texture from Image
version 0.022
use Graphics::Raylib '+family'; use PDL; use PDL::Matrix; my $pdl = mpdl[ [0, 1, 1, 1, 0], [1, 0, 0, 0, 0], [0, 1, 1, 1 ,0], [0, 0, 0, 0 ,1], [0, 1, 1, 1 ,0], ]; my $g = Graphics::Raylib->window(240, 240); $g->fps(60); my $img = Graphics::Raylib::Texture->new(matrix => unpdl($pdl), color => YELLOW, transposed => 1); while (!$g->exiting) { $img->matrix = unpdl($pdl); $img->rotation -= 1; Graphics::Raylib::draw { $g->clear(BLACK); $img->draw; }; # now do some operations on $pdl, to get next iteration }
For drawing images
Prepares the image the for drawing. The image may be specified as file name, by its bytes, an instance of Imager or Graph::Easy or as a series of pixels. pixels' value may be either an array ref of array refs or a string. In all cases except for pixels => string, the size can be omitted and it will be inferred from the image.
file
bytes
pixels
pixels => string
size
Specifying fullscreen => 1 overrides height and width.
fullscreen => 1
height
width
Creates a texture out of a matrix for printing. $AoA is an array of arrays ref. $image_width and $image_height are the size of the area on which the Matrix should be drawn. It's optional defaults to the screen size.
$AoA
$image_width
$image_height
If $color is a Graphics::Raylib::Color, it will be used to color all positive $AoA elements. The space occupied by negative and zero elements stays at background color.
$color
Graphics::Raylib::Color
if $color is a code reference, It will be evaluated for each matrix element, with the element's value as argument. The return type of the code reference will be used for the color. Return undef, for omitting the element (drawing it transparently). $color == undef is an unsafe but faster shorthand for $color = sub { shift }.
undef
$color == undef
$color = sub { shift }
transposed => determines whether the image should be drawn transposed ( x,y flipped ). It's more effecient than transposing in a separate step.
transposed =>
rotate => sets an angle (in degrees) for rotation. Rotation origin is the center of the image.
rotate =>
See the game of life example at Graphics::Raylib (or t/30-game-of-life.t) for a more complete example.
t/30-game-of-life.t
Call this while in a Graphics::Raylib::draw block in order to draw the image to screen.
Graphics::Raylib::draw
By default, the texture will be drawn centered.
Flip the image in the specified orientation
lvalue subroutine returning the image's underlying Graphics::Raylib::XS::Image
Graphics::Raylib::XS::Image
Reload texture from image
http://github.com/athreef/Graphics-Raylib
Graphics::Raylib Graphics::Raylib::Shape
Ahmad Fatoum <athreef@cpan.org>, http://a3f.at
<athreef@cpan.org>
Copyright (C) 2018 Ahmad Fatoum
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Graphics::Raylib, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Graphics::Raylib
CPAN shell
perl -MCPAN -e shell install Graphics::Raylib
For more information on module installation, please visit the detailed CPAN module installation guide.