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

Side by Side Diff: experimental/SkV8Example/Path.cpp

Issue 161223002: Add conicTo(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 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 unified diff | Download patch
« no previous file with comments | « experimental/SkV8Example/Path.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 * 7 *
8 */ 8 */
9 9
10 #include "Path.h" 10 #include "Path.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 constructor->InstanceTemplate()->SetInternalFieldCount(1); 44 constructor->InstanceTemplate()->SetInternalFieldCount(1);
45 45
46 ADD_METHOD("closePath", ClosePath); 46 ADD_METHOD("closePath", ClosePath);
47 ADD_METHOD("moveTo", MoveTo); 47 ADD_METHOD("moveTo", MoveTo);
48 ADD_METHOD("lineTo", LineTo); 48 ADD_METHOD("lineTo", LineTo);
49 ADD_METHOD("quadraticCurveTo", QuadraticCurveTo); 49 ADD_METHOD("quadraticCurveTo", QuadraticCurveTo);
50 ADD_METHOD("bezierCurveTo", BezierCurveTo); 50 ADD_METHOD("bezierCurveTo", BezierCurveTo);
51 ADD_METHOD("arc", Arc); 51 ADD_METHOD("arc", Arc);
52 ADD_METHOD("rect", Rect); 52 ADD_METHOD("rect", Rect);
53 ADD_METHOD("oval", Oval); 53 ADD_METHOD("oval", Oval);
54 ADD_METHOD("conicTo", ConicTo);
54 55
55 context->Global()->Set(String::NewFromUtf8( 56 context->Global()->Set(String::NewFromUtf8(
56 gGlobal->getIsolate(), "Path"), constructor->GetFunction()); 57 gGlobal->getIsolate(), "Path"), constructor->GetFunction());
57 } 58 }
58 59
59 Path* Path::Unwrap(const v8::FunctionCallbackInfo<Value>& args) { 60 Path* Path::Unwrap(const v8::FunctionCallbackInfo<Value>& args) {
60 Handle<External> field = Handle<External>::Cast( 61 Handle<External> field = Handle<External>::Cast(
61 args.This()->GetInternalField(0)); 62 args.This()->GetInternalField(0));
62 void* ptr = field->Value(); 63 void* ptr = field->Value();
63 return static_cast<Path*>(ptr); 64 return static_cast<Path*>(ptr);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 Path* path = Unwrap(args); 212 Path* path = Unwrap(args);
212 SkRect rect = { 213 SkRect rect = {
213 SkDoubleToScalar(x-radiusX), 214 SkDoubleToScalar(x-radiusX),
214 SkDoubleToScalar(y-radiusX), 215 SkDoubleToScalar(y-radiusX),
215 SkDoubleToScalar(x+radiusY), 216 SkDoubleToScalar(x+radiusY),
216 SkDoubleToScalar(y+radiusY) 217 SkDoubleToScalar(y+radiusY)
217 }; 218 };
218 219
219 path->fSkPath.addOval(rect, dir); 220 path->fSkPath.addOval(rect, dir);
220 } 221 }
222
223 void Path::ConicTo(const v8::FunctionCallbackInfo<Value>& args) {
224 if (args.Length() != 5) {
225 args.GetIsolate()->ThrowException(
226 v8::String::NewFromUtf8(
227 args.GetIsolate(), "Error: 5 args required."));
228 return;
229 }
230 double x1 = args[0]->NumberValue();
231 double y1 = args[1]->NumberValue();
232 double x2 = args[2]->NumberValue();
233 double y2 = args[3]->NumberValue();
234 double w = args[4]->NumberValue();
235 Path* path = Unwrap(args);
236
237 path->fSkPath.conicTo(
238 SkDoubleToScalar(x1),
239 SkDoubleToScalar(y1),
240 SkDoubleToScalar(x2),
241 SkDoubleToScalar(y2),
242 SkDoubleToScalar(w)
243 );
244 }
OLDNEW
« no previous file with comments | « experimental/SkV8Example/Path.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698