diff --git a/src/context2d.cc b/src/context2d.cc index 650233f..5eb565d 100644 --- a/src/context2d.cc +++ b/src/context2d.cc @@ -107,6 +107,7 @@ Context2d::Initialize(Handle target) { proto->SetAccessor(String::NewSymbol("lineJoin"), GetLineJoin, SetLineJoin); proto->SetAccessor(String::NewSymbol("shadowOffsetX"), GetShadowOffsetX, SetShadowOffsetX); proto->SetAccessor(String::NewSymbol("shadowOffsetY"), GetShadowOffsetY, SetShadowOffsetY); + proto->SetAccessor(String::NewSymbol("shadowBlur"), GetShadowBlur, SetShadowBlur); target->Set(String::NewSymbol("CanvasRenderingContext2d"), t->GetFunction()); } @@ -132,6 +133,7 @@ Context2d::Context2d(Canvas *canvas): ObjectWrap() { _context = cairo_create(canvas->getSurface()); cairo_set_line_width(_context, 1); fillPattern = strokePattern = NULL; + shadowBlur = shadowOffsetX = shadowOffsetY = 0; globalAlpha = -1; RGBA(fill,0,0,0,1); RGBA(stroke,0,0,0,1); @@ -272,6 +274,29 @@ Context2d::SetShadowOffsetY(Local prop, Local val, const Accessor context->shadowOffsetY = val->NumberValue(); } +/* + * Get shadow blur. + */ + +Handle +Context2d::GetShadowBlur(Local prop, const AccessorInfo &info) { + Context2d *context = ObjectWrap::Unwrap(info.This()); + return Number::New(context->shadowBlur); +} + +/* + * Set shadow blur. + */ + +void +Context2d::SetShadowBlur(Local prop, Local val, const AccessorInfo &info) { + double n = val->NumberValue(); + if (n > 0) { + Context2d *context = ObjectWrap::Unwrap(info.This()); + context->shadowBlur = n; + } +} + /* * Get miter limit. */ diff --git a/src/context2d.h b/src/context2d.h index c8fd6fe..f0786e6 100644 --- a/src/context2d.h +++ b/src/context2d.h @@ -24,6 +24,7 @@ class Context2d: public node::ObjectWrap { rgba_t fill; rgba_t stroke; rgba_t shadow; + double shadowBlur; double shadowOffsetX; double shadowOffsetY; cairo_pattern_t *fillPattern; @@ -66,6 +67,7 @@ class Context2d: public node::ObjectWrap { static Handle GetLineWidth(Local prop, const AccessorInfo &info); static Handle GetShadowOffsetX(Local prop, const AccessorInfo &info); static Handle GetShadowOffsetY(Local prop, const AccessorInfo &info); + static Handle GetShadowBlur(Local prop, const AccessorInfo &info); static void SetGlobalCompositeOperation(Local prop, Local val, const AccessorInfo &info); static void SetGlobalAlpha(Local prop, Local val, const AccessorInfo &info); static void SetMiterLimit(Local prop, Local val, const AccessorInfo &info); @@ -74,6 +76,7 @@ class Context2d: public node::ObjectWrap { static void SetLineWidth(Local prop, Local val, const AccessorInfo &info); static void SetShadowOffsetX(Local prop, Local val, const AccessorInfo &info); static void SetShadowOffsetY(Local prop, Local val, const AccessorInfo &info); + static void SetShadowBlur(Local prop, Local val, const AccessorInfo &info); inline cairo_t *getContext(){ return _context; } inline Canvas *getCanvas(){ return _canvas; }