From f5cedb3c130069c514a8bc0c79c69e184d676037 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Tue, 5 Oct 2010 16:10:40 -0700 Subject: [PATCH] Added isPointInPath() (not yet working) --- src/context2d.cc | 14 ++++++++++++++ src/context2d.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/context2d.cc b/src/context2d.cc index db53ccf..1ac6487 100644 --- a/src/context2d.cc +++ b/src/context2d.cc @@ -79,6 +79,7 @@ Context2d::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(t, "translate", Translate); NODE_SET_PROTOTYPE_METHOD(t, "transform", Transform); NODE_SET_PROTOTYPE_METHOD(t, "resetTransform", ResetTransform); + NODE_SET_PROTOTYPE_METHOD(t, "isPointInPath", IsPointInPath); NODE_SET_PROTOTYPE_METHOD(t, "scale", Scale); NODE_SET_PROTOTYPE_METHOD(t, "clip", Clip); NODE_SET_PROTOTYPE_METHOD(t, "fill", Fill); @@ -344,6 +345,19 @@ Context2d::SetLineCap(Local prop, Local val, const AccessorInfo & } } +Handle +Context2d::IsPointInPath(const Arguments &args) { + HandleScope scope; + if (args[0]->IsNumber() && args[1]->IsNumber()) { + Context2d *context = ObjectWrap::Unwrap(args.This()); + cairo_t *ctx = context->getContext(); + double x = args[0]->NumberValue() + , y = args[1]->NumberValue(); + return Boolean::New(cairo_in_fill(ctx, x, y)); + } + return False(); +} + /* * Set fill pattern, used internally for fillStyle= */ diff --git a/src/context2d.h b/src/context2d.h index a61f452..e46e9e3 100644 --- a/src/context2d.h +++ b/src/context2d.h @@ -31,6 +31,7 @@ class Context2d: public node::ObjectWrap { static Handle Scale(const Arguments &args); static Handle Transform(const Arguments &args); static Handle ResetTransform(const Arguments &args); + static Handle IsPointInPath(const Arguments &args); static Handle BeginPath(const Arguments &args); static Handle ClosePath(const Arguments &args); static Handle Clip(const Arguments &args);