diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index 3a1d7a1..5fb2c69 100755 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -383,12 +383,7 @@ Context2d::shadow(void (fn)(cairo_t *cr)) { // draw the path and blur cairo_new_path(shadow_context); cairo_append_path(shadow_context, path); - cairo_set_source_rgba( - shadow_context - , state->shadow.r - , state->shadow.g - , state->shadow.b - , state->shadow.a * state->globalAlpha); + setSourceRGBA(shadow_context, state->shadow); fn(shadow_context); blur(shadow_surface, state->shadowBlur); @@ -429,13 +424,22 @@ Context2d::shadow(void (fn)(cairo_t *cr)) { } /* - * Set source RGBA. + * Set source RGBA for the current context */ void Context2d::setSourceRGBA(rgba_t color) { + setSourceRGBA(_context, color); +} + +/* + * Set source RGBA + */ + +void +Context2d::setSourceRGBA(cairo_t *ctx, rgba_t color) { cairo_set_source_rgba( - _context + ctx , color.r , color.g , color.b diff --git a/src/CanvasRenderingContext2d.h b/src/CanvasRenderingContext2d.h index c29ae3b..b5920a5 100644 --- a/src/CanvasRenderingContext2d.h +++ b/src/CanvasRenderingContext2d.h @@ -150,6 +150,7 @@ class Context2d: public node::ObjectWrap { inline Canvas *canvas(){ return _canvas; } inline bool hasShadow(); void inline setSourceRGBA(rgba_t color); + void inline setSourceRGBA(cairo_t *ctx, rgba_t color); void setTextPath(const char *str, double x, double y); void blur(cairo_surface_t *surface, int radius); void shadow(void (fn)(cairo_t *cr));