Browse Source

Stubbed FillText() and StrokeText()

v1.x
Tj Holowaychuk 14 years ago
parent
commit
1d90aa950a
  1. 30
      lib/canvas.js
  2. 28
      src/CanvasRenderingContext2d.cc
  3. 2
      src/CanvasRenderingContext2d.h

30
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.
*

28
src/CanvasRenderingContext2d.cc

@ -97,6 +97,8 @@ Context2d::Initialize(Handle<Object> 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<Value>
Context2d::FillText(const Arguments &args) {
HandleScope scope;
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_t *ctx = context->getContext();
SET_SOURCE(context->state->fill);
return Undefined();
}
/*
* Stroke text at (x ,y).
*/
Handle<Value>
Context2d::StrokeText(const Arguments &args) {
HandleScope scope;
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_t *ctx = context->getContext();
SET_SOURCE(context->state->fill);
return Undefined();
}
/*
* Adds a point to the current subpath.
*/

2
src/CanvasRenderingContext2d.h

@ -60,6 +60,8 @@ class Context2d: public node::ObjectWrap {
static Handle<Value> Clip(const Arguments &args);
static Handle<Value> Fill(const Arguments &args);
static Handle<Value> Stroke(const Arguments &args);
static Handle<Value> FillText(const Arguments &args);
static Handle<Value> StrokeText(const Arguments &args);
static Handle<Value> SetFont(const Arguments &args);
static Handle<Value> SetFillRGBA(const Arguments &args);
static Handle<Value> SetStrokeRGBA(const Arguments &args);

Loading…
Cancel
Save