Browse Source

Started strokeText()

v1.x
Tj Holowaychuk 14 years ago
parent
commit
0fbefba998
  1. 28
      src/CanvasRenderingContext2d.cc
  2. 1
      src/CanvasRenderingContext2d.h

28
src/CanvasRenderingContext2d.cc

@ -88,6 +88,7 @@ Context2d::Initialize(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "strokeRect", StrokeRect);
NODE_SET_PROTOTYPE_METHOD(t, "clearRect", ClearRect);
NODE_SET_PROTOTYPE_METHOD(t, "rect", Rect);
NODE_SET_PROTOTYPE_METHOD(t, "strokeText", StrokeText);
NODE_SET_PROTOTYPE_METHOD(t, "fillText", FillText);
NODE_SET_PROTOTYPE_METHOD(t, "moveTo", MoveTo);
NODE_SET_PROTOTYPE_METHOD(t, "lineTo", LineTo);
@ -843,6 +844,33 @@ Context2d::SetFont(const Arguments &args) {
return Undefined();
}
/*
* Stroke text at x, y.
*/
Handle<Value>
Context2d::StrokeText(const Arguments &args) {
HandleScope scope;
// Ignore when args are not present
if (!args[0]->IsString()
|| !args[1]->IsNumber()
|| !args[2]->IsNumber()) return Undefined();
String::Utf8Value str(args[0]);
double x = args[1]->NumberValue()
, y = args[2]->NumberValue();
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_t *ctx = context->getContext();
cairo_text_extents_t te;
cairo_move_to(ctx, x, y);
cairo_show_text(ctx, *str);
return Undefined();
}
/*
* Fill text at x, y.
*/

1
src/CanvasRenderingContext2d.h

@ -64,6 +64,7 @@ class Context2d: public node::ObjectWrap {
static Handle<Value> SetShadowRGBA(const Arguments &args);
static Handle<Value> SetFillPattern(const Arguments &args);
static Handle<Value> SetStrokePattern(const Arguments &args);
static Handle<Value> StrokeText(const Arguments &args);
static Handle<Value> FillText(const Arguments &args);
static Handle<Value> BezierCurveTo(const Arguments &args);
static Handle<Value> QuadraticCurveTo(const Arguments &args);

Loading…
Cancel
Save