|
|
@ -41,8 +41,6 @@ NAN_METHOD(Pattern::New) { |
|
|
|
return Nan::ThrowTypeError("Class constructors cannot be invoked without 'new'"); |
|
|
|
} |
|
|
|
|
|
|
|
int w = 0 |
|
|
|
, h = 0; |
|
|
|
cairo_surface_t *surface; |
|
|
|
|
|
|
|
Local<Object> obj = info[0]->ToObject(); |
|
|
@ -53,15 +51,11 @@ NAN_METHOD(Pattern::New) { |
|
|
|
if (!img->isComplete()) { |
|
|
|
return Nan::ThrowError("Image given has not completed loading"); |
|
|
|
} |
|
|
|
w = img->width; |
|
|
|
h = img->height; |
|
|
|
surface = img->surface(); |
|
|
|
|
|
|
|
// Canvas
|
|
|
|
} else if (Nan::New(Canvas::constructor)->HasInstance(obj)) { |
|
|
|
Canvas *canvas = Nan::ObjectWrap::Unwrap<Canvas>(obj); |
|
|
|
w = canvas->width; |
|
|
|
h = canvas->height; |
|
|
|
surface = canvas->surface(); |
|
|
|
|
|
|
|
// Invalid
|
|
|
@ -69,7 +63,7 @@ NAN_METHOD(Pattern::New) { |
|
|
|
return Nan::ThrowTypeError("Image or Canvas expected"); |
|
|
|
} |
|
|
|
|
|
|
|
Pattern *pattern = new Pattern(surface,w,h); |
|
|
|
Pattern *pattern = new Pattern(surface); |
|
|
|
pattern->Wrap(info.This()); |
|
|
|
info.GetReturnValue().Set(info.This()); |
|
|
|
} |
|
|
@ -79,8 +73,7 @@ NAN_METHOD(Pattern::New) { |
|
|
|
* Initialize linear gradient. |
|
|
|
*/ |
|
|
|
|
|
|
|
Pattern::Pattern(cairo_surface_t *surface, int w, int h): |
|
|
|
_width(w), _height(h) { |
|
|
|
Pattern::Pattern(cairo_surface_t *surface) { |
|
|
|
_pattern = cairo_pattern_create_for_surface(surface); |
|
|
|
} |
|
|
|
|
|
|
|