Browse Source

setting up shadowColor accessors

v1.x
Tj Holowaychuk 15 years ago
parent
commit
0ff539c691
  1. 10
      lib/context2d.js
  2. 30
      src/CanvasRenderingContext2d.cc
  3. 3
      src/CanvasRenderingContext2d.h

10
lib/context2d.js

@ -153,16 +153,6 @@ Context2d.prototype.__defineSetter__('strokeStyle', function(val){
} }
}); });
/**
* Set the shadow color with the given css color string.
*
* @api public
*/
Context2d.prototype.__defineSetter__('shadowColor', function(val){
this.setShadowColor(val);
});
/** /**
* Set font. * Set font.
* *

30
src/CanvasRenderingContext2d.cc

@ -90,13 +90,13 @@ Context2d::Initialize(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(constructor, "arc", Arc); NODE_SET_PROTOTYPE_METHOD(constructor, "arc", Arc);
NODE_SET_PROTOTYPE_METHOD(constructor, "arcTo", ArcTo); NODE_SET_PROTOTYPE_METHOD(constructor, "arcTo", ArcTo);
NODE_SET_PROTOTYPE_METHOD(constructor, "setFont", SetFont); NODE_SET_PROTOTYPE_METHOD(constructor, "setFont", SetFont);
NODE_SET_PROTOTYPE_METHOD(constructor, "setShadowColor", SetShadowColor);
NODE_SET_PROTOTYPE_METHOD(constructor, "setFillColor", SetFillColor); NODE_SET_PROTOTYPE_METHOD(constructor, "setFillColor", SetFillColor);
NODE_SET_PROTOTYPE_METHOD(constructor, "setStrokeColor", SetStrokeColor); NODE_SET_PROTOTYPE_METHOD(constructor, "setStrokeColor", SetStrokeColor);
NODE_SET_PROTOTYPE_METHOD(constructor, "setFillPattern", SetFillPattern); NODE_SET_PROTOTYPE_METHOD(constructor, "setFillPattern", SetFillPattern);
NODE_SET_PROTOTYPE_METHOD(constructor, "setStrokePattern", SetStrokePattern); NODE_SET_PROTOTYPE_METHOD(constructor, "setStrokePattern", SetStrokePattern);
proto->SetAccessor(String::NewSymbol("globalCompositeOperation"), GetGlobalCompositeOperation, SetGlobalCompositeOperation); proto->SetAccessor(String::NewSymbol("globalCompositeOperation"), GetGlobalCompositeOperation, SetGlobalCompositeOperation);
proto->SetAccessor(String::NewSymbol("globalAlpha"), GetGlobalAlpha, SetGlobalAlpha); proto->SetAccessor(String::NewSymbol("globalAlpha"), GetGlobalAlpha, SetGlobalAlpha);
proto->SetAccessor(String::NewSymbol("shadowColor"), GetShadowColor, SetShadowColor);
proto->SetAccessor(String::NewSymbol("miterLimit"), GetMiterLimit, SetMiterLimit); proto->SetAccessor(String::NewSymbol("miterLimit"), GetMiterLimit, SetMiterLimit);
proto->SetAccessor(String::NewSymbol("lineWidth"), GetLineWidth, SetLineWidth); proto->SetAccessor(String::NewSymbol("lineWidth"), GetLineWidth, SetLineWidth);
proto->SetAccessor(String::NewSymbol("lineCap"), GetLineCap, SetLineCap); proto->SetAccessor(String::NewSymbol("lineCap"), GetLineCap, SetLineCap);
@ -989,20 +989,28 @@ Context2d::SetStrokePattern(const Arguments &args) {
} }
/* /*
* Set shadow color, used internally for shadowColor= * Set shadow color.
*/ */
Handle<Value> void
Context2d::SetShadowColor(const Arguments &args) { Context2d::SetShadowColor(Local<String> prop, Local<Value> val, const AccessorInfo &info) {
HandleScope scope;
short ok; short ok;
if (!args[0]->IsString()) return Undefined(); String::AsciiValue str(val->ToString());
String::AsciiValue str(args[0]);
uint32_t rgba = rgba_from_string(*str, &ok); uint32_t rgba = rgba_from_string(*str, &ok);
if (!ok) return Undefined(); if (ok) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
context->state->shadow = rgba_create(rgba); context->state->shadow = rgba_create(rgba);
return Undefined(); }
}
/*
* Get shadow color.
*/
Handle<Value>
Context2d::GetShadowColor(Local<String> prop, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
return Null();
} }
/* /*

3
src/CanvasRenderingContext2d.h

@ -62,7 +62,6 @@ class Context2d: public node::ObjectWrap {
static Handle<Value> SetFont(const Arguments &args); static Handle<Value> SetFont(const Arguments &args);
static Handle<Value> SetFillColor(const Arguments &args); static Handle<Value> SetFillColor(const Arguments &args);
static Handle<Value> SetStrokeColor(const Arguments &args); static Handle<Value> SetStrokeColor(const Arguments &args);
static Handle<Value> SetShadowColor(const Arguments &args);
static Handle<Value> SetFillPattern(const Arguments &args); static Handle<Value> SetFillPattern(const Arguments &args);
static Handle<Value> SetStrokePattern(const Arguments &args); static Handle<Value> SetStrokePattern(const Arguments &args);
static Handle<Value> SetTextBaseline(const Arguments &args); static Handle<Value> SetTextBaseline(const Arguments &args);
@ -80,6 +79,7 @@ class Context2d: public node::ObjectWrap {
static Handle<Value> ArcTo(const Arguments &args); static Handle<Value> ArcTo(const Arguments &args);
static Handle<Value> GetGlobalCompositeOperation(Local<String> prop, const AccessorInfo &info); static Handle<Value> GetGlobalCompositeOperation(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetGlobalAlpha(Local<String> prop, const AccessorInfo &info); static Handle<Value> GetGlobalAlpha(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetShadowColor(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetMiterLimit(Local<String> prop, const AccessorInfo &info); static Handle<Value> GetMiterLimit(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetLineCap(Local<String> prop, const AccessorInfo &info); static Handle<Value> GetLineCap(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetLineJoin(Local<String> prop, const AccessorInfo &info); static Handle<Value> GetLineJoin(Local<String> prop, const AccessorInfo &info);
@ -90,6 +90,7 @@ class Context2d: public node::ObjectWrap {
static Handle<Value> GetAntiAlias(Local<String> prop, const AccessorInfo &info); static Handle<Value> GetAntiAlias(Local<String> prop, const AccessorInfo &info);
static void SetGlobalCompositeOperation(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetGlobalCompositeOperation(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetGlobalAlpha(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetGlobalAlpha(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetShadowColor(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetMiterLimit(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetMiterLimit(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetLineCap(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetLineCap(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetLineJoin(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetLineJoin(Local<String> prop, Local<Value> val, const AccessorInfo &info);

Loading…
Cancel
Save