Browse Source

Added transform()

v1.x
Tj Holowaychuk 14 years ago
parent
commit
c48fc469b3
  1. 24
      src/context2d.cc
  2. 1
      src/context2d.h

24
src/context2d.cc

@ -84,6 +84,7 @@ Context2d::Initialize(Handle<Object> 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, "transform", Transform);
NODE_SET_PROTOTYPE_METHOD(t, "scale", Scale);
NODE_SET_PROTOTYPE_METHOD(t, "fill", Fill);
NODE_SET_PROTOTYPE_METHOD(t, "stroke", Stroke);
@ -363,6 +364,29 @@ Context2d::Rotate(const Arguments &args) {
return Undefined();
}
/*
* Transform.
*/
Handle<Value>
Context2d::Transform(const Arguments &args) {
HandleScope scope;
cairo_matrix_t matrix;
cairo_matrix_init(&matrix
, args[0]->IsNumber() ? args[0]->NumberValue() : 0
, args[1]->IsNumber() ? args[1]->NumberValue() : 0
, args[2]->IsNumber() ? args[2]->NumberValue() : 0
, args[3]->IsNumber() ? args[3]->NumberValue() : 0
, args[4]->IsNumber() ? args[4]->NumberValue() : 0
, args[5]->IsNumber() ? args[5]->NumberValue() : 0);
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_transform(context->getContext(), &matrix);
return Undefined();
}
/*
* Translate transformation.
*/

1
src/context2d.h

@ -26,6 +26,7 @@ class Context2d: public node::ObjectWrap {
static Handle<Value> Rotate(const Arguments &args);
static Handle<Value> Translate(const Arguments &args);
static Handle<Value> Scale(const Arguments &args);
static Handle<Value> Transform(const Arguments &args);
static Handle<Value> BeginPath(const Arguments &args);
static Handle<Value> ClosePath(const Arguments &args);
static Handle<Value> Fill(const Arguments &args);

Loading…
Cancel
Save