Browse Source

Added save() / restore()

v1.x
Tj Holowaychuk 15 years ago
parent
commit
72a762627e
  1. 26
      src/context2d.cc
  2. 2
      src/context2d.h

26
src/context2d.cc

@ -84,6 +84,8 @@ Context2d::Initialize(Handle<Object> target) {
// Prototype
Local<ObjectTemplate> proto = t->PrototypeTemplate();
NODE_SET_PROTOTYPE_METHOD(t, "save", Save);
NODE_SET_PROTOTYPE_METHOD(t, "restore", Restore);
NODE_SET_PROTOTYPE_METHOD(t, "fill", Fill);
NODE_SET_PROTOTYPE_METHOD(t, "stroke", Stroke);
NODE_SET_PROTOTYPE_METHOD(t, "fillRect", FillRect);
@ -306,6 +308,30 @@ Context2d::BezierCurveTo(const Arguments &args) {
return Undefined();
}
/*
* Save state.
*/
Handle<Value>
Context2d::Save(const Arguments &args) {
HandleScope scope;
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_save(context->getContext());
return Undefined();
}
/*
* Restore state.
*/
Handle<Value>
Context2d::Restore(const Arguments &args) {
HandleScope scope;
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_restore(context->getContext());
return Undefined();
}
/*
* Creates a new subpath.
*/

2
src/context2d.h

@ -21,6 +21,8 @@ class Context2d: public node::ObjectWrap {
rgba_t stroke;
static void Initialize(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
static Handle<Value> Save(const Arguments &args);
static Handle<Value> Restore(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