Browse Source

Refactor setSourceRGBA to allow the context to be supplied.

v1.x
Andy Wood 10 years ago
parent
commit
822d822066
  1. 20
      src/CanvasRenderingContext2d.cc
  2. 1
      src/CanvasRenderingContext2d.h

20
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

1
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));

Loading…
Cancel
Save