/* 
 * Ming/Ruby
 * $Id: swffill.c,v 1.6 2002/06/13 11:04:37 daisu-ik Exp $
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <ming.h>
#include "ruby.h"
#include "ming_ruby.h"

VALUE rb_cSWFFill;

void rb_SWFFill_free(p)
	 struct RSWFFill *p;
{
  destroySWFFill(p->this);

  return;
}

static VALUE
rb_SWFFill_move_to(self, x, y)
	 VALUE self, x, y;
{
  struct RSWFFill *f;

  Data_Get_Struct(self, struct RSWFFill, f);
  SWFFill_moveTo(f->this, NUM2DBL(x), NUM2DBL(y));
  
  return self;
}

static VALUE
rb_SWFFill_scale_to(argc, argv, self)
	 int argc;
	 VALUE *argv, self;
{
  VALUE x, y;
  struct RSWFFill *f;

  rb_scan_args(argc, argv, "11", &x, &y);
  
  Data_Get_Struct(self, struct RSWFFill, f);

  if (NIL_P(y))
	SWFFill_scaleTo(f->this, NUM2DBL(x), NUM2DBL(x));
  else
	SWFFill_scaleTo(f->this, NUM2DBL(x), NUM2DBL(y));
  
  return self;
}

static VALUE
rb_SWFFill_rotate_to(self, d)
	 VALUE self, d;
{
  struct RSWFFill *f;

  Data_Get_Struct(self, struct RSWFFill, f);
  SWFFill_rotateTo(f->this, NUM2DBL(d));
  
  return self;
}

static VALUE
rb_SWFFill_skew_x_to(self, x)
	 VALUE self, x;
{
  struct RSWFFill *f;

  Data_Get_Struct(self, struct RSWFFill, f);
  SWFFill_skewXTo(f->this, NUM2DBL(x));
  
  return self;
}

static VALUE
rb_SWFFill_skew_y_to(self, y)
	 VALUE self, y;
{
  struct RSWFFill *f;

  Data_Get_Struct(self, struct RSWFFill, f);
  SWFFill_skewXTo(f->this, NUM2DBL(y));
  
  return self;
}

static VALUE
rb_SWFFill_scale_x_to(self, x)
	 VALUE self, x;
{
  struct RSWFFill *f;

  Data_Get_Struct(self, struct RSWFFill, f);
  SWFFill_scaleXTo(f->this, NUM2DBL(x));
  
  return self;
}

static VALUE
rb_SWFFill_scale_y_to(self, y)
	 VALUE self, y;
{
  struct RSWFFill *f;

  Data_Get_Struct(self, struct RSWFFill, f);
  SWFFill_scaleYTo(f->this, NUM2DBL(y));
  
  return self;
}

static VALUE
rb_SWFFill_set_matrix(self, a, b, c, d, x, y)
	 VALUE self, a, b, c, d, x, y;
{
  struct RSWFFill *f;

  Data_Get_Struct(self, struct RSWFFill, f);
  SWFFill_setMatrix(f->this, NUM2DBL(a), NUM2DBL(b),
		    NUM2DBL(c), NUM2DBL(d),
		    NUM2DBL(x), NUM2DBL(y));
  
  return self;
}

void Init_swffill()
{
  rb_cSWFFill = rb_define_class_under(rb_mMing, "SWFFill", rb_cObject);

  rb_define_method(rb_cSWFFill, "move_to",
				   rb_SWFFill_move_to, 2);
  rb_define_method(rb_cSWFFill, "scale_to",
				   rb_SWFFill_scale_to, -1);
  rb_define_method(rb_cSWFFill, "rotate_to",
				   rb_SWFFill_rotate_to, 1);
  rb_define_method(rb_cSWFFill, "skew_x_to",
				   rb_SWFFill_skew_x_to, 1);
  rb_define_method(rb_cSWFFill, "skew_y_to",
				   rb_SWFFill_skew_y_to, 1);
  rb_define_method(rb_cSWFFill, "scale_x_to",
				   rb_SWFFill_scale_x_to, 1);
  rb_define_method(rb_cSWFFill, "scale_y_to",
				   rb_SWFFill_scale_y_to, 1);
  rb_define_method(rb_cSWFFill, "set_matrix",
				   rb_SWFFill_set_matrix, 6);

  return;
}

