Browse Source

Added setTransform(). Closes #15

v1.x
Tj Holowaychuk 14 years ago
parent
commit
7336835d3c
  1. 5
      lib/canvas.js
  2. 15
      src/context2d.cc
  3. 1
      src/context2d.h

5
lib/canvas.js

@ -146,6 +146,11 @@ Context2d.prototype.createRadialGradient = function(x0, y0, r0, x1, y1, r1){
return new CanvasGradient(x0, y0, r0, x1, y1, r1);
};
Context2d.prototype.setTransform = function(){
this.resetTransform();
return this.transform.apply(this, arguments);
};
/**
* Set the fill style with the given css color string.
*

15
src/context2d.cc

@ -78,6 +78,7 @@ Context2d::Initialize(Handle<Object> target) {
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, "resetTransform", ResetTransform);
NODE_SET_PROTOTYPE_METHOD(t, "scale", Scale);
NODE_SET_PROTOTYPE_METHOD(t, "fill", Fill);
NODE_SET_PROTOTYPE_METHOD(t, "stroke", Stroke);
@ -485,7 +486,7 @@ Context2d::Rotate(const Arguments &args) {
}
/*
* Transform.
* Modify the CTM.
*/
Handle<Value>
@ -507,6 +508,18 @@ Context2d::Transform(const Arguments &args) {
return Undefined();
}
/*
* Reset the CTM, used internally by setTransform().
*/
Handle<Value>
Context2d::ResetTransform(const Arguments &args) {
HandleScope scope;
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_identity_matrix(context->getContext());
return Undefined();
}
/*
* Translate transformation.
*/

1
src/context2d.h

@ -30,6 +30,7 @@ class Context2d: public node::ObjectWrap {
static Handle<Value> Translate(const Arguments &args);
static Handle<Value> Scale(const Arguments &args);
static Handle<Value> Transform(const Arguments &args);
static Handle<Value> ResetTransform(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