Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2596)

Unified Diff: experimental/SkV8Example/Path.cpp

Issue 132413002: Just use one version of the scripts in both the browser and in SkV8. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: merge Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/SkV8Example/Path.h ('k') | experimental/SkV8Example/SkV8Example.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/SkV8Example/Path.cpp
diff --git a/experimental/SkV8Example/Path.cpp b/experimental/SkV8Example/Path.cpp
index 2b53a0f8e16ba9cdc2eb8c60bb683a16580c7bfb..90574f40f031f892563daeb1244a5dbc82708f6d 100644
--- a/experimental/SkV8Example/Path.cpp
+++ b/experimental/SkV8Example/Path.cpp
@@ -43,13 +43,14 @@ void Path::AddToGlobal(Global* global) {
gGlobal->getIsolate(), Path::ConstructPath);
constructor->InstanceTemplate()->SetInternalFieldCount(1);
- ADD_METHOD("close", ClosePath);
+ ADD_METHOD("closePath", ClosePath);
ADD_METHOD("moveTo", MoveTo);
ADD_METHOD("lineTo", LineTo);
ADD_METHOD("quadraticCurveTo", QuadraticCurveTo);
ADD_METHOD("bezierCurveTo", BezierCurveTo);
ADD_METHOD("arc", Arc);
ADD_METHOD("rect", Rect);
+ ADD_METHOD("oval", Oval);
context->Global()->Set(String::NewFromUtf8(
gGlobal->getIsolate(), "Path"), constructor->GetFunction());
@@ -191,3 +192,29 @@ void Path::Rect(const v8::FunctionCallbackInfo<Value>& args) {
Path* path = Unwrap(args);
path->fSkPath.addRect(rect);
}
+
+void Path::Oval(const v8::FunctionCallbackInfo<Value>& args) {
+ if (args.Length() != 4 && args.Length() != 5) {
+ args.GetIsolate()->ThrowException(
+ v8::String::NewFromUtf8(
+ args.GetIsolate(), "Error: 4 or 5 args required."));
+ return;
+ }
+ double x = args[0]->NumberValue();
+ double y = args[1]->NumberValue();
+ double radiusX = args[2]->NumberValue();
+ double radiusY = args[3]->NumberValue();
+ SkPath::Direction dir = SkPath::kCW_Direction;
+ if (args.Length() == 5 && !args[4]->BooleanValue()) {
+ dir = SkPath::kCCW_Direction;
+ }
+ Path* path = Unwrap(args);
+ SkRect rect = {
+ SkDoubleToScalar(x-radiusX),
+ SkDoubleToScalar(y-radiusX),
+ SkDoubleToScalar(x+radiusY),
+ SkDoubleToScalar(y+radiusY)
+ };
+
+ path->fSkPath.addOval(rect, dir);
+}
« no previous file with comments | « experimental/SkV8Example/Path.h ('k') | experimental/SkV8Example/SkV8Example.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698