Add conicTo().

BUG=skia:
R=robertphillips@google.com

Author: jcgregorio@google.com

Review URL: https://codereview.chromium.org/161223002

git-svn-id: http://skia.googlecode.com/svn/trunk@13431 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-02-13 16:00:58 +00:00
parent ea7d08e3bb
commit e1df56579f
2 changed files with 25 additions and 0 deletions

View File

@ -51,6 +51,7 @@ void Path::AddToGlobal(Global* global) {
ADD_METHOD("arc", Arc);
ADD_METHOD("rect", Rect);
ADD_METHOD("oval", Oval);
ADD_METHOD("conicTo", ConicTo);
context->Global()->Set(String::NewFromUtf8(
gGlobal->getIsolate(), "Path"), constructor->GetFunction());
@ -218,3 +219,26 @@ void Path::Oval(const v8::FunctionCallbackInfo<Value>& args) {
path->fSkPath.addOval(rect, dir);
}
void Path::ConicTo(const v8::FunctionCallbackInfo<Value>& args) {
if (args.Length() != 5) {
args.GetIsolate()->ThrowException(
v8::String::NewFromUtf8(
args.GetIsolate(), "Error: 5 args required."));
return;
}
double x1 = args[0]->NumberValue();
double y1 = args[1]->NumberValue();
double x2 = args[2]->NumberValue();
double y2 = args[3]->NumberValue();
double w = args[4]->NumberValue();
Path* path = Unwrap(args);
path->fSkPath.conicTo(
SkDoubleToScalar(x1),
SkDoubleToScalar(y1),
SkDoubleToScalar(x2),
SkDoubleToScalar(y2),
SkDoubleToScalar(w)
);
}

View File

@ -40,6 +40,7 @@ public:
static void Arc(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Rect(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Oval(const v8::FunctionCallbackInfo<v8::Value>& args);
static void ConicTo(const v8::FunctionCallbackInfo<v8::Value>& args);
private:
SkPath fSkPath;