Browse Source

Added lineWidth accessor

v1.x
Tj Holowaychuk 14 years ago
parent
commit
aae9de3109
  1. 22
      src/context2d.cc
  2. 2
      src/context2d.h

22
src/context2d.cc

@ -82,6 +82,7 @@ Context2d::Initialize(Handle<Object> target) {
t->SetClassName(String::NewSymbol("Context2d"));
// Prototype
Local<ObjectTemplate> proto = t->PrototypeTemplate();
NODE_SET_PROTOTYPE_METHOD(t, "fill", Fill);
NODE_SET_PROTOTYPE_METHOD(t, "stroke", Stroke);
NODE_SET_PROTOTYPE_METHOD(t, "fillRect", FillRect);
@ -95,6 +96,7 @@ Context2d::Initialize(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "arc", Arc);
NODE_SET_PROTOTYPE_METHOD(t, "setFillRGBA", SetFillRGBA);
NODE_SET_PROTOTYPE_METHOD(t, "setStrokeRGBA", SetStrokeRGBA);
proto->SetAccessor(String::NewSymbol("lineWidth"), GetLineWidth, SetLineWidth);
target->Set(String::NewSymbol("Context2d"), t->GetFunction());
}
@ -130,6 +132,26 @@ Context2d::~Context2d() {
cairo_destroy(_context);
}
/*
* Get line width.
*/
Handle<Value>
Context2d::GetLineWidth(Local<String> prop, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
return Number::New(cairo_get_line_width(context->getContext()));
}
/*
* Set line width.
*/
void
Context2d::SetLineWidth(Local<String> prop, Local<Value> val, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
cairo_set_line_width(context->getContext(), val->NumberValue());
}
/*
* Set fill RGBA, used internally for fillStyle=
*/

2
src/context2d.h

@ -34,6 +34,8 @@ class Context2d: public node::ObjectWrap {
static Handle<Value> StrokeRect(const Arguments &args);
static Handle<Value> ClearRect(const Arguments &args);
static Handle<Value> Arc(const Arguments &args);
static Handle<Value> GetLineWidth(Local<String> prop, const AccessorInfo &info);
static void SetLineWidth(Local<String> prop, Local<Value> val, const AccessorInfo &info);
inline cairo_t *getContext(){ return _context; }
inline Canvas *getCanvas(){ return _canvas; }

Loading…
Cancel
Save