Browse Source

prep for c color parser

v1.x
Tj Holowaychuk 14 years ago
parent
commit
97c7fe6dbd
  1. 4
      lib/context2d.js
  2. 24
      src/CanvasRenderingContext2d.cc
  3. 6
      src/CanvasRenderingContext2d.h

4
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);
}
});

24
src/CanvasRenderingContext2d.cc

@ -100,9 +100,9 @@ Context2d::Initialize(Handle<Object> 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<Value>
Context2d::SetShadowRGBA(const Arguments &args) {
Context2d::SetShadowColor(const Arguments &args) {
HandleScope scope;
RGBA_ARGS(0);
Context2d *context = ObjectWrap::Unwrap<Context2d>(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<Value>
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<Context2d>(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<Value>
Context2d::SetStrokeRGBA(const Arguments &args) {
Context2d::SetStrokeColor(const Arguments &args) {
HandleScope scope;
RGBA_ARGS(0);
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());

6
src/CanvasRenderingContext2d.h

@ -67,9 +67,9 @@ class Context2d: public node::ObjectWrap {
static Handle<Value> FillText(const Arguments &args);
static Handle<Value> StrokeText(const Arguments &args);
static Handle<Value> SetFont(const Arguments &args);
static Handle<Value> SetFillRGBA(const Arguments &args);
static Handle<Value> SetStrokeRGBA(const Arguments &args);
static Handle<Value> SetShadowRGBA(const Arguments &args);
static Handle<Value> SetFillColor(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> SetStrokePattern(const Arguments &args);
static Handle<Value> SetTextBaseline(const Arguments &args);

Loading…
Cancel
Save