From 97c7fe6dbd9429d888494cb500c65cf23576770a Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Tue, 23 Nov 2010 14:21:19 -0800 Subject: [PATCH] prep for c color parser --- lib/context2d.js | 4 ++-- src/CanvasRenderingContext2d.cc | 24 +++++++++++++----------- src/CanvasRenderingContext2d.h | 6 +++--- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/context2d.js b/lib/context2d.js index b0ddef6..ea461f0 100644 --- a/lib/context2d.js +++ b/lib/context2d.js @@ -134,7 +134,7 @@ Context2d.prototype.__defineSetter__('fillStyle', function(val){ this.lastFillStyle = val; this.setFillPattern(val); } else if ('string' == typeof val) { - this.setFillStyle(val); + this.setFillColor(val); } }); @@ -149,7 +149,7 @@ Context2d.prototype.__defineSetter__('strokeStyle', function(val){ this.lastStrokeStyle = val; this.setStrokePattern(val); } else if ('string' == typeof val) { - this.setStrokeStyle(val); + this.setStrokeColor(val); } }); diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index 5ac2756..c8bac13 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -100,9 +100,9 @@ Context2d::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(constructor, "arc", Arc); NODE_SET_PROTOTYPE_METHOD(constructor, "arcTo", ArcTo); NODE_SET_PROTOTYPE_METHOD(constructor, "setFont", SetFont); - NODE_SET_PROTOTYPE_METHOD(constructor, "setShadowRGBA", SetShadowRGBA); - NODE_SET_PROTOTYPE_METHOD(constructor, "setFillRGBA", SetFillRGBA); - NODE_SET_PROTOTYPE_METHOD(constructor, "setStrokeRGBA", SetStrokeRGBA); + NODE_SET_PROTOTYPE_METHOD(constructor, "setShadowColor", SetShadowColor); + NODE_SET_PROTOTYPE_METHOD(constructor, "setFillColor", SetFillColor); + NODE_SET_PROTOTYPE_METHOD(constructor, "setStrokeColor", SetStrokeColor); NODE_SET_PROTOTYPE_METHOD(constructor, "setFillPattern", SetFillPattern); NODE_SET_PROTOTYPE_METHOD(constructor, "setStrokePattern", SetStrokePattern); proto->SetAccessor(String::NewSymbol("globalCompositeOperation"), GetGlobalCompositeOperation, SetGlobalCompositeOperation); @@ -997,11 +997,11 @@ Context2d::SetStrokePattern(const Arguments &args) { } /* - * Set shadow RGBA, used internally for shadowColor= + * Set shadow color, used internally for shadowColor= */ Handle -Context2d::SetShadowRGBA(const Arguments &args) { +Context2d::SetShadowColor(const Arguments &args) { HandleScope scope; RGBA_ARGS(0); Context2d *context = ObjectWrap::Unwrap(args.This()); @@ -1010,25 +1010,27 @@ Context2d::SetShadowRGBA(const Arguments &args) { } /* - * Set fill RGBA, used internally for fillStyle= + * Set fill color, used internally for fillStyle= */ Handle -Context2d::SetFillRGBA(const Arguments &args) { +Context2d::SetFillColor(const Arguments &args) { HandleScope scope; - RGBA_ARGS(0); + if (!args[0]->IsString()) return Undefined(); + String::AsciiValue str(args[0]); + printf("%s\n", *str); Context2d *context = ObjectWrap::Unwrap(args.This()); context->state->fillPattern = NULL; - RGBA(context->state->fill,r,g,b,a); + //RGBA(context->state->fill,r,g,b,a); return Undefined(); } /* - * Set stroke RGBA, used internally for strokeStyle= + * Set stroke color, used internally for strokeStyle= */ Handle -Context2d::SetStrokeRGBA(const Arguments &args) { +Context2d::SetStrokeColor(const Arguments &args) { HandleScope scope; RGBA_ARGS(0); Context2d *context = ObjectWrap::Unwrap(args.This()); diff --git a/src/CanvasRenderingContext2d.h b/src/CanvasRenderingContext2d.h index b11409a..da89432 100644 --- a/src/CanvasRenderingContext2d.h +++ b/src/CanvasRenderingContext2d.h @@ -67,9 +67,9 @@ class Context2d: public node::ObjectWrap { static Handle FillText(const Arguments &args); static Handle StrokeText(const Arguments &args); static Handle SetFont(const Arguments &args); - static Handle SetFillRGBA(const Arguments &args); - static Handle SetStrokeRGBA(const Arguments &args); - static Handle SetShadowRGBA(const Arguments &args); + static Handle SetFillColor(const Arguments &args); + static Handle SetStrokeColor(const Arguments &args); + static Handle SetShadowColor(const Arguments &args); static Handle SetFillPattern(const Arguments &args); static Handle SetStrokePattern(const Arguments &args); static Handle SetTextBaseline(const Arguments &args);