Browse Source

Defaulting rotate() / translate()

v1.x
Tj Holowaychuk 15 years ago
parent
commit
ed85e434a0
  1. 19
      src/context2d.cc

19
src/context2d.cc

@ -365,13 +365,9 @@ Context2d::ClosePath(const Arguments &args) {
Handle<Value> Handle<Value>
Context2d::Rotate(const Arguments &args) { Context2d::Rotate(const Arguments &args) {
HandleScope scope; HandleScope scope;
if (!args[0]->IsNumber())
return ThrowException(Exception::TypeError(String::New("angle required")));
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_rotate(context->getContext(), args[0]->NumberValue()); cairo_rotate(context->getContext()
, args[0]->IsNumber() ? args[0]->NumberValue() : 0);
return Undefined(); return Undefined();
} }
@ -382,17 +378,10 @@ Context2d::Rotate(const Arguments &args) {
Handle<Value> Handle<Value>
Context2d::Translate(const Arguments &args) { Context2d::Translate(const Arguments &args) {
HandleScope scope; 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<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_translate(context->getContext() cairo_translate(context->getContext()
, args[0]->NumberValue() , args[0]->IsNumber() ? args[0]->NumberValue() : 0
, args[1]->NumberValue()); , args[1]->IsNumber() ? args[1]->NumberValue() : 0);
return Undefined(); return Undefined();
} }

Loading…
Cancel
Save