Browse Source

Added shadowOffset{Y,X} accessors

v1.x
Tj Holowaychuk 14 years ago
parent
commit
5a147368c5
  1. 42
      src/context2d.cc
  2. 6
      src/context2d.h

42
src/context2d.cc

@ -105,6 +105,8 @@ Context2d::Initialize(Handle<Object> target) {
proto->SetAccessor(String::NewSymbol("lineWidth"), GetLineWidth, SetLineWidth);
proto->SetAccessor(String::NewSymbol("lineCap"), GetLineCap, SetLineCap);
proto->SetAccessor(String::NewSymbol("lineJoin"), GetLineJoin, SetLineJoin);
proto->SetAccessor(String::NewSymbol("shadowOffsetX"), GetShadowOffsetX, SetShadowOffsetX);
proto->SetAccessor(String::NewSymbol("shadowOffsetY"), GetShadowOffsetY, SetShadowOffsetY);
target->Set(String::NewSymbol("CanvasRenderingContext2d"), t->GetFunction());
}
@ -230,6 +232,46 @@ Context2d::SetGlobalCompositeOperation(Local<String> prop, Local<Value> val, con
}
}
/*
* Get shadow offset x.
*/
Handle<Value>
Context2d::GetShadowOffsetX(Local<String> prop, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
return Number::New(context->shadowOffsetX);
}
/*
* Set shadow offset x.
*/
void
Context2d::SetShadowOffsetX(Local<String> prop, Local<Value> val, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
context->shadowOffsetX = val->NumberValue();
}
/*
* Get shadow offset y.
*/
Handle<Value>
Context2d::GetShadowOffsetY(Local<String> prop, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
return Number::New(context->shadowOffsetY);
}
/*
* Set shadow offset y.
*/
void
Context2d::SetShadowOffsetY(Local<String> prop, Local<Value> val, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
context->shadowOffsetY = val->NumberValue();
}
/*
* Get miter limit.
*/

6
src/context2d.h

@ -24,6 +24,8 @@ class Context2d: public node::ObjectWrap {
rgba_t fill;
rgba_t stroke;
rgba_t shadow;
double shadowOffsetX;
double shadowOffsetY;
cairo_pattern_t *fillPattern;
cairo_pattern_t *strokePattern;
float globalAlpha;
@ -62,12 +64,16 @@ class Context2d: public node::ObjectWrap {
static Handle<Value> GetLineCap(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetLineJoin(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> GetShadowOffsetY(Local<String> prop, 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 SetMiterLimit(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetLineCap(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetLineJoin(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 SetShadowOffsetY(Local<String> prop, Local<Value> val, const AccessorInfo &info);
inline cairo_t *getContext(){ return _context; }
inline Canvas *getCanvas(){ return _canvas; }

Loading…
Cancel
Save