From ed85e434a04d80a1a73050e33e8d6988be0aa821 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Wed, 29 Sep 2010 15:16:24 -0700 Subject: [PATCH] Defaulting rotate() / translate() --- src/context2d.cc | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/context2d.cc b/src/context2d.cc index dac61b2..3ec4bd9 100644 --- a/src/context2d.cc +++ b/src/context2d.cc @@ -365,13 +365,9 @@ Context2d::ClosePath(const Arguments &args) { Handle Context2d::Rotate(const Arguments &args) { HandleScope scope; - - if (!args[0]->IsNumber()) - return ThrowException(Exception::TypeError(String::New("angle required"))); - Context2d *context = ObjectWrap::Unwrap(args.This()); - cairo_rotate(context->getContext(), args[0]->NumberValue()); - + cairo_rotate(context->getContext() + , args[0]->IsNumber() ? args[0]->NumberValue() : 0); return Undefined(); } @@ -382,17 +378,10 @@ Context2d::Rotate(const Arguments &args) { Handle Context2d::Translate(const Arguments &args) { HandleScope scope; - - if (!args[0]->IsNumber()) - return ThrowException(Exception::TypeError(String::New("tx required"))); - if (!args[1]->IsNumber()) - return ThrowException(Exception::TypeError(String::New("ty required"))); - Context2d *context = ObjectWrap::Unwrap(args.This()); cairo_translate(context->getContext() - , args[0]->NumberValue() - , args[1]->NumberValue()); - + , args[0]->IsNumber() ? args[0]->NumberValue() : 0 + , args[1]->IsNumber() ? args[1]->NumberValue() : 0); return Undefined(); }