From 1d90aa950a6fe1180448c04150dbf023fcc1506f Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Wed, 3 Nov 2010 16:19:49 -0700 Subject: [PATCH] Stubbed FillText() and StrokeText() --- lib/canvas.js | 30 ------------------------------ src/CanvasRenderingContext2d.cc | 28 ++++++++++++++++++++++++++++ src/CanvasRenderingContext2d.h | 2 ++ 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/canvas.js b/lib/canvas.js index 0b9a093..8f309a3 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -349,36 +349,6 @@ Context2d.prototype.setTransform = function(){ this.transform.apply(this, arguments); }; -/** - * Stroke `text` at (`x`, `y`). - * - * @param {String} text - * @param {Number} x - * @param {Number} y - * @api public - */ - -Context2d.prototype.strokeText = function(text, x, y){ - this.beginPath(); - this.setTextPath(text, x, y); - return this.stroke(); -}; - -/** - * Fill `text` at (`x`, `y`). - * - * @param {String} text - * @param {Number} x - * @param {Number} y - * @api public - */ - -Context2d.prototype.fillText = function(text, x, y){ - this.beginPath(); - this.setTextPath(text, x, y); - return this.fill(); -}; - /** * Set the fill style with the given css color string. * diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index 2222c88..4404876 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -97,6 +97,8 @@ Context2d::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(t, "clip", Clip); NODE_SET_PROTOTYPE_METHOD(t, "fill", Fill); NODE_SET_PROTOTYPE_METHOD(t, "stroke", Stroke); + NODE_SET_PROTOTYPE_METHOD(t, "fillText", FillText); + NODE_SET_PROTOTYPE_METHOD(t, "strokeText", StrokeText); NODE_SET_PROTOTYPE_METHOD(t, "fillRect", FillRect); NODE_SET_PROTOTYPE_METHOD(t, "strokeRect", StrokeRect); NODE_SET_PROTOTYPE_METHOD(t, "clearRect", ClearRect); @@ -767,6 +769,32 @@ Context2d::Stroke(const Arguments &args) { return Undefined(); } +/* + * Fill text at (x, y). + */ + +Handle +Context2d::FillText(const Arguments &args) { + HandleScope scope; + Context2d *context = ObjectWrap::Unwrap(args.This()); + cairo_t *ctx = context->getContext(); + SET_SOURCE(context->state->fill); + return Undefined(); +} + +/* + * Stroke text at (x ,y). + */ + +Handle +Context2d::StrokeText(const Arguments &args) { + HandleScope scope; + Context2d *context = ObjectWrap::Unwrap(args.This()); + cairo_t *ctx = context->getContext(); + SET_SOURCE(context->state->fill); + return Undefined(); +} + /* * Adds a point to the current subpath. */ diff --git a/src/CanvasRenderingContext2d.h b/src/CanvasRenderingContext2d.h index 6b9006b..abec1ce 100644 --- a/src/CanvasRenderingContext2d.h +++ b/src/CanvasRenderingContext2d.h @@ -60,6 +60,8 @@ class Context2d: public node::ObjectWrap { static Handle Clip(const Arguments &args); static Handle Fill(const Arguments &args); static Handle Stroke(const Arguments &args); + static Handle FillText(const Arguments &args); + static Handle StrokeText(const Arguments &args); static Handle SetFont(const Arguments &args); static Handle SetFillRGBA(const Arguments &args); static Handle SetStrokeRGBA(const Arguments &args);