Browse Source

Added shadowBlur accessor

v1.x
Tj Holowaychuk 14 years ago
parent
commit
9e4352a6fd
  1. 25
      src/context2d.cc
  2. 3
      src/context2d.h

25
src/context2d.cc

@ -107,6 +107,7 @@ Context2d::Initialize(Handle<Object> target) {
proto->SetAccessor(String::NewSymbol("lineJoin"), GetLineJoin, SetLineJoin); proto->SetAccessor(String::NewSymbol("lineJoin"), GetLineJoin, SetLineJoin);
proto->SetAccessor(String::NewSymbol("shadowOffsetX"), GetShadowOffsetX, SetShadowOffsetX); proto->SetAccessor(String::NewSymbol("shadowOffsetX"), GetShadowOffsetX, SetShadowOffsetX);
proto->SetAccessor(String::NewSymbol("shadowOffsetY"), GetShadowOffsetY, SetShadowOffsetY); proto->SetAccessor(String::NewSymbol("shadowOffsetY"), GetShadowOffsetY, SetShadowOffsetY);
proto->SetAccessor(String::NewSymbol("shadowBlur"), GetShadowBlur, SetShadowBlur);
target->Set(String::NewSymbol("CanvasRenderingContext2d"), t->GetFunction()); target->Set(String::NewSymbol("CanvasRenderingContext2d"), t->GetFunction());
} }
@ -132,6 +133,7 @@ Context2d::Context2d(Canvas *canvas): ObjectWrap() {
_context = cairo_create(canvas->getSurface()); _context = cairo_create(canvas->getSurface());
cairo_set_line_width(_context, 1); cairo_set_line_width(_context, 1);
fillPattern = strokePattern = NULL; fillPattern = strokePattern = NULL;
shadowBlur = shadowOffsetX = shadowOffsetY = 0;
globalAlpha = -1; globalAlpha = -1;
RGBA(fill,0,0,0,1); RGBA(fill,0,0,0,1);
RGBA(stroke,0,0,0,1); RGBA(stroke,0,0,0,1);
@ -272,6 +274,29 @@ Context2d::SetShadowOffsetY(Local<String> prop, Local<Value> val, const Accessor
context->shadowOffsetY = val->NumberValue(); context->shadowOffsetY = val->NumberValue();
} }
/*
* Get shadow blur.
*/
Handle<Value>
Context2d::GetShadowBlur(Local<String> prop, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
return Number::New(context->shadowBlur);
}
/*
* Set shadow blur.
*/
void
Context2d::SetShadowBlur(Local<String> prop, Local<Value> val, const AccessorInfo &info) {
double n = val->NumberValue();
if (n > 0) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
context->shadowBlur = n;
}
}
/* /*
* Get miter limit. * Get miter limit.
*/ */

3
src/context2d.h

@ -24,6 +24,7 @@ class Context2d: public node::ObjectWrap {
rgba_t fill; rgba_t fill;
rgba_t stroke; rgba_t stroke;
rgba_t shadow; rgba_t shadow;
double shadowBlur;
double shadowOffsetX; double shadowOffsetX;
double shadowOffsetY; double shadowOffsetY;
cairo_pattern_t *fillPattern; cairo_pattern_t *fillPattern;
@ -66,6 +67,7 @@ class Context2d: public node::ObjectWrap {
static Handle<Value> GetLineWidth(Local<String> prop, const AccessorInfo &info); static Handle<Value> GetLineWidth(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetShadowOffsetX(Local<String> prop, const AccessorInfo &info); static Handle<Value> GetShadowOffsetX(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetShadowOffsetY(Local<String> prop, const AccessorInfo &info); static Handle<Value> GetShadowOffsetY(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetShadowBlur(Local<String> prop, const AccessorInfo &info);
static void SetGlobalCompositeOperation(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetGlobalCompositeOperation(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetGlobalAlpha(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetGlobalAlpha(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetMiterLimit(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetMiterLimit(Local<String> prop, Local<Value> val, const AccessorInfo &info);
@ -74,6 +76,7 @@ class Context2d: public node::ObjectWrap {
static void SetLineWidth(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetLineWidth(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetShadowOffsetX(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetShadowOffsetX(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetShadowOffsetY(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetShadowOffsetY(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; }

Loading…
Cancel
Save