X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDLx-Surface.html-inc;h=34e51ec55d86ac726aac505e9707a54a391ee603;hb=a3de848879a5553418ed11fb193c4bf286ca7120;hp=0148bde8228abff7cfa58bf034695b159cbb2d82;hpb=807ae0cdf3bf7e415bbb01449976c9ab91209cbb;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDLx-Surface.html-inc b/pages/SDLx-Surface.html-inc index 0148bde..34e51ec 100644 --- a/pages/SDLx-Surface.html-inc +++ b/pages/SDLx-Surface.html-inc @@ -19,14 +19,19 @@
  • EXTENSIONS -
    @@ -85,9 +90,9 @@ SDLx::Surface->new( width=> 400, height=>200, flags=> SDL_SWSURFACE, depth=>32, greenmask=>0xFF000000 ) # A SDL::Surface->new( SDL_ANYFORMAT, 400, 200, 32, 0, 0xFF000000,0, 0, 0 ) is loaded - - - + SDLx::Surface->new( w => 1, h => 1, color => 0xFF0000FF ) + # A SDL::Surface->new( SDL_ANYFORMAT, 1, 1, 32, 0, 0, 0, 0 ) is loaded + all pixels are colored with color (red) @@ -106,6 +111,7 @@
     SDLx::Surface::display( width => 20, height => 20, flags=> SDL_HWSURFACE, depth=>24) 
     
     
    +

    You can also use the keys w and h in place of width and height, as with new.

    Get or create the main display surface and attach to a SDLx::Surface.

    @@ -137,16 +143,49 @@
    +

    load

    +
    +
     my $surface = SDLx::Surface->load( 'hero.png' );
    + my $surface = SDLx::Surface->load( 'hero.dat', 'bmp' );
    +
    +
    +

    Loads the given image file into a new SDLx::Surface surface. A new +surface is always created, even if you call it from an already crafted +object. Croaks on errors such as no support built for that image extension +or a file reading error (the error message is SDL::get_error and should +give more details).

    +

    Note that load() will automatically figure out the extension based on the +filename you provide. If you wish to force an extension for whatever reason +(like having a filename with a different extension or none at all), you can +optionally pass the file type as a second parameter. Case is not relevant.

    +

    If you don't have SDL_image in your build, only bitmap images will be +supported.

    +

    Returns the new Surface.

    + + + + + +

    blit

     $sdlx_surface->blit( $dest, $src_rect, $dest_rect );
     
     

    Blits SDLx::Surface onto $dest surface. -$src_rect or $dest_rect are optional. $src_rect or $dest_rect can be array refs or SDL::Rect. $dest can be SDLx::Surface or SDL::Surface.

    +$src_rect or $dest_rect are optional. If $src_rect is ommited, it will be the size of the entire surface. If $dest_rect is ommited, it will be blitted at (0, 0). $src_rect or $dest_rect can be array refs or SDL::Rect. $dest can be SDLx::Surface or SDL::Surface.

    Returns $self

    +

    blit_by

    +
    +
     $sdlx_surface->blit_by( $src, $src_rect, $dest_rect );
    +
    +
    +

    Does the same as blit but the SDLx::Surface is the one being blitted to. +This is useful when the surface you have isn't an SDLx::Surface, but the surface it is being blitted to is.

    + +

    flip

    Applies SDL::Video::flip to the Surface, with error checking.

    @@ -175,7 +214,7 @@ $src_rect or $dest_rect are optional. $src_rect or $dest_rect can be array refs $sdlx_surface->draw_rect( SDL::Rect->new($x,$y,$w,$h), 0xFFFF00FF ); -

    Draws a rect on the surface with the given color.

    +

    Draws a rect on the surface with the given color. If the rect is ommited, the colored rect will be drawn to the entire surface.

    Returns $self

    @@ -185,15 +224,59 @@ $src_rect or $dest_rect are optional. $src_rect or $dest_rect can be array refs $sdlx_surface->draw_line( [$x1, $y1], [$x2, $y2], \@color, $antialias); # -

    Draws a line on the surface. Antialias is turned on if $antialias is defined.

    +

    Draws a line on the surface. Antialias is turned on if $antialias is true.

    +

    Returns $self

    + + +

    draw_circle

    +
    +
     $sdlx_surface->draw_circle( [$x1, $y1], $radius, \@color ); 
    +
    +
    +

    Draws an unfilled circle at ($x1,$y1) of size $radius and $color.

    Returns $self

    -

    AUTHOR

    Top

    -
    -
     kthakore 
    +

    draw_circle_filled

    +
    +
     $sdlx_surface->draw_filled_circle( [$x1, $y1], $radius, \@color ); 
     
     
    +

    Draws an filled circle at ($x1,$y1) of size $radius and $color.

    +

    Returns $self

    + + + + + + + + +
    +

    draw_gfx_text

    +
    +

    Draw text using gfx (not pretty but fast) at give vector, color.

    +
     $surf->draw_gfx_text( [0,0], 0xffffffff, "fooo");
    + $surf->draw_gfx_text( [10,10], [20,20,20,20], "fooo");
    +
    +
    +

    You can also set the gfx font but passing a hash reference as shown below.

    +
     my $f = '';
    + open( my $FH, '<', 'test/data/5x7.fnt');
    + binmode ($FH);
    + read($FH, $f, 4096);
    + close ($FH);
    +
    + my $font =  {data=>$f, cw => 5, ch => 7};
    + $surf->draw_gfx_text( [0,0], 0xffffffff, "fooo", $font );
    +
    +
    +

    Returns $self

    + +
    +

    AUTHORS

    Top

    +
    +

    See AUTHORS in SDL.

    \ No newline at end of file