static VALUE Drawable_initialize(int argc, VALUE *argv, VALUE vSelf) { // Get C++ object pointer from vSelf Drawable *pSelf; Data_Get_Struct(vSelf, Drawable, pSelf); if(argc == 0) { // Nothing to initialize } else if(argc >= 1 && argc <= 5 && (argc < 5 || IS(argv[4], g_cColor))) { if(argc >= 1) pSelf->SetLeft((float)NUM2DBL(argv[0])); if(argc >= 2) pSelf->SetTop((float)NUM2DBL(argv[1])); if(argc >= 3) { if(ISNUM(argv[2])) { float f = (float)NUM2DBL(argv[2]); pSelf->SetScale(f, f); } else if(IS(argv[2], rb_cArray)) { float x = (float)NUM2DBL(rb_ary_entry(argv[2], 0)); float y = (float)NUM2DBL(rb_ary_entry(argv[2], 1)); pSelf->SetScale(x, y); } } if(argc >= 4) pSelf->SetRotation((float)NUM2DBL(argv[3])); if(argc >= 5) pSelf->SetColor(*(Color *)DATA_PTR(argv[4])); } else rb_raise(rb_eTypeError, "wrong argument type(s)"); return vSelf; }
static VALUE Drawable_set_color(VALUE vSelf, VALUE vColor) { // Get C++ object pointer from vSelf Drawable *pSelf; Data_Get_Struct(vSelf, Drawable, pSelf); if(!IS(vColor, g_cColor)) rb_raise(rb_eTypeError, "wrong argument type(s)"); pSelf->SetColor(*(Color *)DATA_PTR(vColor)); return Qnil; }
void TextDraw::SetText( Drawable & draw, const Font & font, const std::string & text, float x, float y, float scalex, float scaley, float r, float g, float b, VertexArray & output_array) { RenderText(font, text, x, y, scalex, scaley, output_array); draw.SetTextures(font.GetFontTexture()->GetId()); draw.SetVertArray(&output_array); draw.SetCull(false, false); draw.SetColor(r, g, b, 1.0); }