From 06d6f9b81d3934f024fe10c77bdf6bb4863e74de Mon Sep 17 00:00:00 2001 From: groogy Date: Wed, 17 Nov 2010 20:55:20 +0000 Subject: [PATCH] Finished the Rect_Initialize function so we now also can specify two vectors as size and position. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1669 4e206d99-4929-0410-ac5d-dfc041789085 --- bindings/ruby/sfml-graphics/graphics/Rect.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bindings/ruby/sfml-graphics/graphics/Rect.cpp b/bindings/ruby/sfml-graphics/graphics/Rect.cpp index 45c577bf0..6b07d8b63 100644 --- a/bindings/ruby/sfml-graphics/graphics/Rect.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Rect.cpp @@ -21,6 +21,7 @@ */ #include "Rect.hpp" +#include "Vector2.hpp" #include "main.hpp" VALUE globalRectClass; @@ -96,6 +97,8 @@ static void Rect_internal_ValidateTypes( VALUE aFirst, VALUE aSecond, VALUE aThi */ static VALUE Rect_Initialize( int argc, VALUE *args VALUE self ) { + VALUE arg0 = Qnil; + VALUE arg1 = Qnil; switch( argc ) { case 0: @@ -107,6 +110,14 @@ static VALUE Rect_Initialize( int argc, VALUE *args VALUE self ) case 1: Color_internal_CopyFrom( self, args[0] ); break; + case 2: + arg0 = Vector2_ForceType( args[0] ); + arg1 = Vector2_ForceType( args[1] ); + rb_iv_set( self, "@left", rb_funcall( arg0, rb_intern( "x" ), 0 ) ); + rb_iv_set( self, "@top", rb_funcall( arg0, rb_intern( "y" ), 0 ) ); + rb_iv_set( self, "@width", rb_funcall( arg1, rb_intern( "x" ), 0 ) ); + rb_iv_set( self, "@height", rb_funcall( arg2, rb_intern( "y" ), 0 ) ); + break; case 4: Rect_internal_ValidateTypes( args[0], args[1], args[2], args[3] ); rb_iv_set( self, "@left", args[0]);