MCPcopy Create free account
hub / github.com/creationix/node-sdl / GetRGBA

Method GetRGBA

src/sdl.cc:758–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

756}
757
758static Handle<Value> sdl::GetRGBA(const Arguments& args) {
759 HandleScope scope;
760
761 if (!(args.Length() == 2 && args[0]->IsNumber() && args[1]->IsObject())) {
762 return ThrowException(Exception::TypeError(String::New("Invalid arguments: Expected GetRGBA(Number, PixelFormat)")));
763 }
764
765 int pixel = args[0]->Int32Value();
766 SDL_PixelFormat* fmt = UnwrapPixelFormat(args[1]->ToObject());
767 ::Uint8 r, g, b, a;
768
769 SDL_GetRGBA(pixel, fmt, &r, &g, &b, &a);
770
771 Local<Object> rgba = Object::New();
772 rgba->Set(String::New("r"), Number::New(r));
773 rgba->Set(String::New("g"), Number::New(g));
774 rgba->Set(String::New("b"), Number::New(b));
775 rgba->Set(String::New("a"), Number::New(a));
776
777 return scope.Close(rgba);
778}
779
780
781static Handle<Value> sdl::TTF::Init(const Arguments& args) {

Callers

nothing calls this directly

Calls 1

UnwrapPixelFormatFunction · 0.85

Tested by

no test coverage detected