Updated the site
[sdlgit/SDL-Site.git] / pages / SDLx-Surface.html-inc
index 0148bde..c492fc6 100644 (file)
 <ul><li><a href="#surface">surface</a></li>
 <li><a href="#w_h_format_pitch_flags">w, h, format, pitch, flags</a></li>
 <li><a href="#clip_rect">clip_rect</a></li>
-</ul>
-</li>
-<li><a href="#EXTENSIONS">EXTENSIONS</a>
-<ul><li><a href="#blit">blit </a></li>
+<li><a href="#load">load</a></li>
+<li><a href="#blit">blit </a></li>
+<li><a href="#blit_by">blit_by</a></li>
 <li><a href="#flip">flip</a></li>
 <li><a href="#update">update</a></li>
 <li><a href="#draw_rect">draw_rect</a></li>
 <li><a href="#draw_line">draw_line</a></li>
+<li><a href="#draw_circle">draw_circle</a></li>
+<li><a href="#draw_circle_filled">draw_circle_filled</a></li>
+<li><a href="#draw_gfx_text">draw_gfx_text</a></li>
 </ul>
 </li>
-<li><a href="#AUTHOR">AUTHOR</a>
+<li><a href="#AUTHORS">AUTHORS</a>
 </li>
 </ul><hr />
 <!-- INDEX END -->
 
        SDLx::Surface-&gt;new( width=&gt; 400, height=&gt;200, flags=&gt; SDL_SWSURFACE, depth=&gt;32, greenmask=&gt;0xFF000000 )
                # A SDL::Surface-&gt;new( SDL_ANYFORMAT, 400, 200, 32, 0, 0xFF000000,0, 0, 0 ) is loaded
-
-
-
+       SDLx::Surface-&gt;new( w =&gt; 1, h =&gt; 1, color =&gt; 0xFF0000FF )
+               # A SDL::Surface-&gt;new( SDL_ANYFORMAT, 1, 1, 32, 0, 0, 0, 0 ) is loaded
+               all pixels are colored with color (red)
 
 </pre>
 
 </div>
 <h2 id="display">display</h2>
 <div id="display_CONTENT">
-<p>If <a href="http://search.cpan.org/perldoc?SDLx::App::new">SDLx::App::new</a> or <a href="/SDL-Video.html#get_video_mode">SDL::Video::get_video_mode</a> called before then:</p>
+<p>If <a href="/SDLx-App.html#new">SDLx::App::new</a> or <a href="/SDL-Video.html#get_video_mode">SDL::Video::get_video_mode</a> called before then:</p>
 <pre> my $appx = SDLx::Surface::display(); 
 
 </pre>
 <pre> SDLx::Surface::display( width =&gt; 20, height =&gt; 20, flags=&gt; SDL_HWSURFACE, depth=&gt;24) 
 
 </pre>
-<p>Get or create the main display surface and attach to a SDLx::Surface.</p>
+<p>You can also use the keys <code>w</code> and <code>h</code> in place of <code>width</code> and <code>height</code>, as with <code>new</code>.</p>
+<p>Get or create the main display surface and attach to a <code>SDLx::Surface</code>.</p>
 
 </div>
 <h2 id="duplicate">duplicate</h2>
 </div>
 <h2 id="clip_rect">clip_rect</h2>
 <div id="clip_rect_CONTENT">
-<p>Sets the passed <code>SDL::Rect</code> as the new clip_rect for the surface. Returns the SDL::Surface's clip_rect. See <code>SDL::Video::get_clip_rect</code> and <code>SDL::Video::set_clip_rect</code>.</p>
+<p>Sets the passed <code>SDL::Rect</code> as the new clip_rect for the surface. Returns the SDL::Surface's clip_rect. See 
+<a href="/SDL-Video.html#get_clip_rect">SDL::Video::get_clip_rect</a> and <a href="/SDL-Video.html#set_clip_rect">SDL::Video::set_clip_rect</a>.
+=head1 EXTENSIONS</p>
 
 </div>
-<h1 id="EXTENSIONS">EXTENSIONS</h1><p><a href="#TOP" class="toplink">Top</a></p>
-<div id="EXTENSIONS_CONTENT">
+<h2 id="load">load</h2>
+<div id="load_CONTENT">
+<pre> my $surface = SDLx::Surface-&gt;load( 'hero.png' );
+ my $surface = SDLx::Surface-&gt;load( 'hero.dat', 'bmp' );
+
+</pre>
+<p>Loads the given image file into a <i>new</i> SDLx::Surface surface. A new
+surface is <strong>always</strong> 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).</p>
+<p>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.</p>
+<p>If you don't have SDL_image in your build, only bitmap images will be
+supported.</p>
+<p>Returns the new Surface.</p>
+
+
+
+
 
 </div>
 <h2 id="blit">blit </h2>
 <pre> $sdlx_surface-&gt;blit( $dest, $src_rect, $dest_rect );
 
 </pre>
-<p>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. </p>
+<p>Blits <code>SDLx::Surface</code> onto $dest 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 <code>(0, 0)</code>. $src_rect or $dest_rect can be array refs or <code>SDL::Rect</code>. $dest can be <code>SDLx::Surface</code> or <code>SDL::Surface</code>.</p>
 <p>Returns $self</p>
 
 </div>
+<h2 id="blit_by">blit_by</h2>
+<div id="blit_by_CONTENT">
+<pre> $sdlx_surface-&gt;blit_by( $src, $src_rect, $dest_rect );
+
+</pre>
+<p>Does the same as <code>blit</code> but the <code>SDLx::Surface</code> is the one being blitted to.
+This is useful when the surface you have isn't an <code>SDLx::Surface</code>, but the surface it is being blitted to is.</p>
+
+</div>
 <h2 id="flip">flip</h2>
 <div id="flip_CONTENT">
 <p>Applies <a href="/SDL-Video.html#flip">SDL::Video::flip</a> to the Surface, with error checking.</p>
@@ -161,7 +196,8 @@ $src_rect or $dest_rect are optional. $src_rect or $dest_rect can be array refs
  $sdlx_surface-&gt;update( [ SDL::Rect-&gt;new(0,0,1,2) ... ]); # defined rects are updated
 
 </pre>
-<p>Applies <a href="/SDL-Video.html#update_rect">SDL::Video::update_rect</a> for no rect or 1 array ref. Applies <a href="/SDL-Video.html#update_rects">SDL::Video::update_rects</a> for array of <a href="SDL-Rect.html">SDL::Rect</a>s. </p>
+<p>Applies <a href="/SDL-Video.html#update_rect">SDL::Video::update_rect</a> for no rect or 1 array ref. Applies 
+<a href="/SDL-Video.html#update_rects">SDL::Video::update_rects</a> for array of <a href="SDL-Rect.html">SDL::Rect</a>s. </p>
 <p>Returns $self</p>
 
 
@@ -175,7 +211,7 @@ $src_rect or $dest_rect are optional. $src_rect or $dest_rect can be array refs
  $sdlx_surface-&gt;draw_rect( SDL::Rect-&gt;new($x,$y,$w,$h), 0xFFFF00FF );
 
 </pre>
-<p>Draws a rect on the surface with the given color. </p>
+<p>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.</p>
 <p>Returns $self</p>
 
 </div>
@@ -185,15 +221,61 @@ $src_rect or $dest_rect are optional. $src_rect or $dest_rect can be array refs
  $sdlx_surface-&gt;draw_line( [$x1, $y1], [$x2, $y2], \@color, $antialias); # 
 
 </pre>
-<p>Draws a line on the surface. Antialias is turned on if $antialias is defined. </p>
+<p>Draws a line on the surface. Antialias is turned on if $antialias is true. </p>
 <p>Returns $self</p>
 
 </div>
-<h1 id="AUTHOR">AUTHOR</h1><p><a href="#TOP" class="toplink">Top</a></p>
-<div id="AUTHOR_CONTENT">
-<pre> kthakore 
+<h2 id="draw_circle">draw_circle</h2>
+<div id="draw_circle_CONTENT">
+<pre> $sdlx_surface-&gt;draw_circle( [$x1, $y1], $radius, \@color, $antialias ); 
+
+</pre>
+<p>Draws an unfilled circle at <code>($x1,$y1)</code> of size $radius and $color.
+Antialias is turned on if $antialias is true. 
+Returns $self</p>
+
+</div>
+<h2 id="draw_circle_filled">draw_circle_filled</h2>
+<div id="draw_circle_filled_CONTENT">
+<pre> $sdlx_surface-&gt;draw_filled_circle( [$x1, $y1], $radius, \@color ); 
+
+</pre>
+<p>Draws an <strong>filled</strong> circle at <code>($x1,$y1)</code> of size $radius and $color.
+Antialias is turned on automatically. 
+Returns $self</p>
+
+
+
+
+
+
+
+
+</div>
+<h2 id="draw_gfx_text">draw_gfx_text</h2>
+<div id="draw_gfx_text_CONTENT">
+<p>Draw text using gfx (not pretty but fast) at give vector, color.</p>
+<pre> $surf-&gt;draw_gfx_text( [0,0], 0xffffffff, &quot;fooo&quot;);
+ $surf-&gt;draw_gfx_text( [10,10], [20,20,20,20], &quot;fooo&quot;);
 
 </pre>
+<p>You can also set the gfx font but passing a hash reference as shown below.</p>
+<pre> my $f = '';
+ open( my $FH, '&lt;', 'test/data/5x7.fnt');
+ binmode ($FH);
+ read($FH, $f, 4096);
+ close ($FH);
+
+ my $font =  {data=&gt;$f, cw =&gt; 5, ch =&gt; 7};
+ $surf-&gt;draw_gfx_text( [0,0], 0xffffffff, &quot;fooo&quot;, $font );
+
+</pre>
+<p>Returns $self</p>
+
+</div>
+<h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="AUTHORS_CONTENT">
+<p>See <a href="/SDL.html#AUTHORS">/SDL.html#AUTHORS</a>.</p>
 
 </div>
 </div>
\ No newline at end of file