Browse Source

Shadow related props within state

v1.x
Tj Holowaychuk 14 years ago
parent
commit
047c068392
  1. 16
      src/CanvasRenderingContext2d.cc
  2. 8
      src/CanvasRenderingContext2d.h

16
src/CanvasRenderingContext2d.cc

@ -153,8 +153,8 @@ Context2d::Context2d(Canvas *canvas): ObjectWrap() {
_canvas = canvas;
_context = cairo_create(canvas->getSurface());
cairo_set_line_width(_context, 1);
shadowBlur = shadowOffsetX = shadowOffsetY = 0;
state = states[stateno = 0] = (canvas_state_t *) malloc(sizeof(canvas_state_t));
state->shadowBlur = state->shadowOffsetX = state->shadowOffsetY = 0;
state->globalAlpha = 1;
state->textAlignment = -1;
state->fillPattern = state->strokePattern = NULL;
@ -305,7 +305,7 @@ Context2d::SetGlobalCompositeOperation(Local<String> prop, Local<Value> val, con
Handle<Value>
Context2d::GetShadowOffsetX(Local<String> prop, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
return Number::New(context->shadowOffsetX);
return Number::New(context->state->shadowOffsetX);
}
/*
@ -315,7 +315,7 @@ Context2d::GetShadowOffsetX(Local<String> prop, const AccessorInfo &info) {
void
Context2d::SetShadowOffsetX(Local<String> prop, Local<Value> val, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
context->shadowOffsetX = val->NumberValue();
context->state->shadowOffsetX = val->NumberValue();
}
/*
@ -325,7 +325,7 @@ Context2d::SetShadowOffsetX(Local<String> prop, Local<Value> val, const Accessor
Handle<Value>
Context2d::GetShadowOffsetY(Local<String> prop, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
return Number::New(context->shadowOffsetY);
return Number::New(context->state->shadowOffsetY);
}
/*
@ -335,7 +335,7 @@ Context2d::GetShadowOffsetY(Local<String> prop, const AccessorInfo &info) {
void
Context2d::SetShadowOffsetY(Local<String> prop, Local<Value> val, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
context->shadowOffsetY = val->NumberValue();
context->state->shadowOffsetY = val->NumberValue();
}
/*
@ -345,7 +345,7 @@ Context2d::SetShadowOffsetY(Local<String> prop, Local<Value> val, const Accessor
Handle<Value>
Context2d::GetShadowBlur(Local<String> prop, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
return Number::New(context->shadowBlur);
return Number::New(context->state->shadowBlur);
}
/*
@ -357,7 +357,7 @@ Context2d::SetShadowBlur(Local<String> prop, Local<Value> val, const AccessorInf
double n = val->NumberValue();
if (n > 0) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
context->shadowBlur = n;
context->state->shadowBlur = n;
}
}
@ -531,7 +531,7 @@ Context2d::SetShadowRGBA(const Arguments &args) {
HandleScope scope;
RGBA_ARGS(0);
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
RGBA(context->shadow,r,g,b,a);
RGBA(context->state->shadow,r,g,b,a);
return Undefined();
}

8
src/CanvasRenderingContext2d.h

@ -34,6 +34,10 @@ typedef struct {
float globalAlpha;
short textAlignment;
short textBaseline;
rgba_t shadow;
double shadowBlur;
double shadowOffsetX;
double shadowOffsetY;
} canvas_state_t;
class Context2d: public node::ObjectWrap {
@ -41,10 +45,6 @@ class Context2d: public node::ObjectWrap {
short stateno;
canvas_state_t *states[CANVAS_MAX_STATES];
canvas_state_t *state;
rgba_t shadow;
double shadowBlur;
double shadowOffsetX;
double shadowOffsetY;
static void Initialize(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
static Handle<Value> Save(const Arguments &args);

Loading…
Cancel
Save