Browse Source

Implemented shadow coloring

v1.x
Tj Holowaychuk 14 years ago
parent
commit
d7b4eb6e2c
  1. 9
      src/CanvasRenderingContext2d.cc
  2. 2
      src/CanvasRenderingContext2d.h

9
src/CanvasRenderingContext2d.cc

@ -1052,21 +1052,18 @@ Context2d::FillRect(const Arguments &args) {
return Undefined(); return Undefined();
} }
cairo_save(ctx);
cairo_translate( cairo_translate(
ctx ctx
, context->state->shadowOffsetX , context->state->shadowOffsetX
, context->state->shadowOffsetY); , context->state->shadowOffsetY);
cairo_rectangle(ctx, x, y, width, height); cairo_rectangle(ctx, x, y, width, height);
SET_SOURCE(context->state->fill); SET_SOURCE_RGBA(context->state->shadow);
cairo_fill(ctx); cairo_fill(ctx);
Canvas::blur(context->getCanvas()->getSurface(), context->state->shadowBlur); Canvas::blur(context->getCanvas()->getSurface(), context->state->shadowBlur);
cairo_translate( cairo_restore(ctx);
ctx
, -context->state->shadowOffsetX
, -context->state->shadowOffsetY);
context->restorePath(); context->restorePath();
cairo_fill(ctx); cairo_fill(ctx);
return Undefined(); return Undefined();

2
src/CanvasRenderingContext2d.h

@ -100,7 +100,7 @@ class Context2d: public node::ObjectWrap {
static void SetShadowBlur(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetShadowBlur(Local<String> prop, Local<Value> val, const AccessorInfo &info);
inline cairo_t *getContext(){ return _context; } inline cairo_t *getContext(){ return _context; }
inline Canvas *getCanvas(){ return _canvas; } inline Canvas *getCanvas(){ return _canvas; }
bool hasShadow(); inline bool hasShadow();
void setTextPath(const char *str, double x, double y); void setTextPath(const char *str, double x, double y);
void savePath(); void savePath();
void restorePath(); void restorePath();

Loading…
Cancel
Save