|
|
@ -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, "setTextAlignment", SetTextAlignment); |
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setTextPath", SetTextPath); |
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "measureText", MeasureText); |
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "moveTo", MoveTo); |
|
|
@ -139,6 +140,7 @@ Context2d::Context2d(Canvas *canvas): ObjectWrap() { |
|
|
|
shadowBlur = shadowOffsetX = shadowOffsetY = 0; |
|
|
|
state = states[stateno = 0] = (canvas_state_t *) malloc(sizeof(canvas_state_t)); |
|
|
|
state->globalAlpha = 1; |
|
|
|
state->textAlignment -1; |
|
|
|
state->fillPattern = state->strokePattern = NULL; |
|
|
|
RGBA(state->fill,0,0,0,1); |
|
|
|
RGBA(state->stroke,0,0,0,1); |
|
|
@ -866,6 +868,22 @@ Context2d::MeasureText(const Arguments &args) { |
|
|
|
return scope.Close(obj); |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
* Set text alignment. -1 0 1 |
|
|
|
*/ |
|
|
|
|
|
|
|
Handle<Value> |
|
|
|
Context2d::SetTextAlignment(const Arguments &args) { |
|
|
|
HandleScope scope; |
|
|
|
|
|
|
|
if (!args[0]->IsInt32()) return Undefined(); |
|
|
|
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); |
|
|
|
context->state->textAlignment = args[0]->Int32Value(); |
|
|
|
|
|
|
|
return Undefined(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set text path at x, y. |
|
|
|
*/ |
|
|
|