diff --git a/src/context2d.cc b/src/context2d.cc index 9bafb90..db53ccf 100644 --- a/src/context2d.cc +++ b/src/context2d.cc @@ -80,6 +80,7 @@ Context2d::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(t, "transform", Transform); NODE_SET_PROTOTYPE_METHOD(t, "resetTransform", ResetTransform); NODE_SET_PROTOTYPE_METHOD(t, "scale", Scale); + NODE_SET_PROTOTYPE_METHOD(t, "clip", Clip); NODE_SET_PROTOTYPE_METHOD(t, "fill", Fill); NODE_SET_PROTOTYPE_METHOD(t, "stroke", Stroke); NODE_SET_PROTOTYPE_METHOD(t, "fillRect", FillRect); @@ -549,7 +550,20 @@ Context2d::Scale(const Arguments &args) { } /* - * Fill the shape. + * Use path as clipping region. + */ + +Handle +Context2d::Clip(const Arguments &args) { + HandleScope scope; + Context2d *context = ObjectWrap::Unwrap(args.This()); + cairo_t *ctx = context->getContext(); + cairo_clip_preserve(ctx); + return Undefined(); +} + +/* + * Fill the path. */ Handle @@ -563,7 +577,7 @@ Context2d::Fill(const Arguments &args) { } /* - * Stroke the shape. + * Stroke the path. */ Handle diff --git a/src/context2d.h b/src/context2d.h index a242152..a61f452 100644 --- a/src/context2d.h +++ b/src/context2d.h @@ -33,6 +33,7 @@ class Context2d: public node::ObjectWrap { static Handle ResetTransform(const Arguments &args); static Handle BeginPath(const Arguments &args); static Handle ClosePath(const Arguments &args); + static Handle Clip(const Arguments &args); static Handle Fill(const Arguments &args); static Handle Stroke(const Arguments &args); static Handle SetSource(const Arguments &args);