diff --git a/src/context2d.cc b/src/context2d.cc index 9240250..e3e7e37 100644 --- a/src/context2d.cc +++ b/src/context2d.cc @@ -24,6 +24,10 @@ using namespace node; _.b = B / 255 * 1; \ _.a = A; \ +/* + * Set source. + */ + #define SET_SOURCE(C) \ if (C##Pattern) \ cairo_set_source(ctx, C##Pattern); \ @@ -151,8 +155,11 @@ Context2d::GetGlobalAlpha(Local prop, const AccessorInfo &info) { void Context2d::SetGlobalAlpha(Local prop, Local val, const AccessorInfo &info) { - Context2d *context = ObjectWrap::Unwrap(info.This()); - context->globalAlpha = val->NumberValue(); + double n = val->NumberValue(); + if (n >= 0 && n <= 1) { + Context2d *context = ObjectWrap::Unwrap(info.This()); + context->globalAlpha = n; + } } /*