From 757d4968bcbfa57ccdfe528146216eb2376840b5 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Wed, 29 Sep 2010 15:24:39 -0700 Subject: [PATCH] Added scale() --- src/context2d.cc | 15 +++++++++++++++ src/context2d.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/context2d.cc b/src/context2d.cc index 3ec4bd9..f64f201 100644 --- a/src/context2d.cc +++ b/src/context2d.cc @@ -88,6 +88,7 @@ Context2d::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(t, "restore", Restore); NODE_SET_PROTOTYPE_METHOD(t, "rotate", Rotate); NODE_SET_PROTOTYPE_METHOD(t, "translate", Translate); + NODE_SET_PROTOTYPE_METHOD(t, "scale", Scale); NODE_SET_PROTOTYPE_METHOD(t, "fill", Fill); NODE_SET_PROTOTYPE_METHOD(t, "stroke", Stroke); NODE_SET_PROTOTYPE_METHOD(t, "fillRect", FillRect); @@ -385,6 +386,20 @@ Context2d::Translate(const Arguments &args) { return Undefined(); } +/* + * Scale transformation. + */ + +Handle +Context2d::Scale(const Arguments &args) { + HandleScope scope; + Context2d *context = ObjectWrap::Unwrap(args.This()); + cairo_scale(context->getContext() + , args[0]->IsNumber() ? args[0]->NumberValue() : 0 + , args[1]->IsNumber() ? args[1]->NumberValue() : 0); + return Undefined(); +} + /* * Fill the shape. */ diff --git a/src/context2d.h b/src/context2d.h index fed4688..d0ec0b8 100644 --- a/src/context2d.h +++ b/src/context2d.h @@ -25,6 +25,7 @@ class Context2d: public node::ObjectWrap { static Handle Restore(const Arguments &args); static Handle Rotate(const Arguments &args); static Handle Translate(const Arguments &args); + static Handle Scale(const Arguments &args); static Handle BeginPath(const Arguments &args); static Handle ClosePath(const Arguments &args); static Handle Fill(const Arguments &args);