Skip to content

Commit

Permalink
Conditionally support cairo 1.10.0 operators
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Nov 12, 2010
1 parent 899a7a2 commit faec4ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

$ npm install canvas

If not previously installed, you will want to install the [cairo graphics library](http://cairographics.org/download/) version _>= 1.10.0_ first using the package manager available to you, or [building from source](https://github.com/LearnBoost/node-canvas/wiki/_pages).
If not previously installed, you will want to install the [cairo graphics library](http://cairographics.org/download/) version _>= 1.8.6_ first using the package manager available to you, or [building from source](https://github.com/LearnBoost/node-canvas/wiki/_pages).

## Screencasts

Expand Down
18 changes: 12 additions & 6 deletions src/CanvasRenderingContext2d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,11 @@ Context2d::GetGlobalCompositeOperation(Local<String> prop, const AccessorInfo &i
return String::NewSymbol("destination-over");
case CAIRO_OPERATOR_LIGHTEN:
return String::NewSymbol("lighter");
// Non-standard
// supported by resent versions of cairo
#if CAIRO_VERSION_MINOR >= 10
case CAIRO_OPERATOR_DARKEN:
return String::NewSymbol("darkler");
// Non-standard
case CAIRO_OPERATOR_MULTIPLY:
return String::NewSymbol("multiply");
case CAIRO_OPERATOR_SCREEN:
Expand All @@ -453,6 +455,7 @@ Context2d::GetGlobalCompositeOperation(Local<String> prop, const AccessorInfo &i
return String::NewSymbol("hsl-color");
case CAIRO_OPERATOR_HSL_LUMINOSITY:
return String::NewSymbol("hsl-luminosity");
#endif
default:
return String::NewSymbol("source-over");
}
Expand All @@ -469,11 +472,7 @@ Context2d::SetGlobalCompositeOperation(Local<String> prop, Local<Value> val, con
String::AsciiValue type(val->ToString());
if (0 == strcmp("xor", *type)) {
cairo_set_operator(ctx, CAIRO_OPERATOR_XOR);
}else if (0 == strcmp("lighter", *type)) {
cairo_set_operator(ctx, CAIRO_OPERATOR_LIGHTEN);
}else if (0 == strcmp("darker", *type)) {
cairo_set_operator(ctx, CAIRO_OPERATOR_DARKEN);
}else if (0 == strcmp("source-atop", *type)) {
} else if (0 == strcmp("source-atop", *type)) {
cairo_set_operator(ctx, CAIRO_OPERATOR_ATOP);
} else if (0 == strcmp("source-in", *type)) {
cairo_set_operator(ctx, CAIRO_OPERATOR_IN);
Expand All @@ -487,7 +486,13 @@ Context2d::SetGlobalCompositeOperation(Local<String> prop, Local<Value> val, con
cairo_set_operator(ctx, CAIRO_OPERATOR_DEST_OUT);
} else if (0 == strcmp("destination-over", *type)) {
cairo_set_operator(ctx, CAIRO_OPERATOR_DEST_OVER);
} else if (0 == strcmp("lighter", *type)) {
cairo_set_operator(ctx, CAIRO_OPERATOR_LIGHTEN);
// Non-standard
// supported by resent versions of cairo
#if CAIRO_VERSION_MINOR >= 10
} else if (0 == strcmp("darker", *type)) {
cairo_set_operator(ctx, CAIRO_OPERATOR_DARKEN);
} else if (0 == strcmp("multiply", *type)) {
cairo_set_operator(ctx, CAIRO_OPERATOR_MULTIPLY);
} else if (0 == strcmp("screen", *type)) {
Expand All @@ -506,6 +511,7 @@ Context2d::SetGlobalCompositeOperation(Local<String> prop, Local<Value> val, con
cairo_set_operator(ctx, CAIRO_OPERATOR_HSL_COLOR);
} else if (0 == strcmp("hsl-luminosity", *type)) {
cairo_set_operator(ctx, CAIRO_OPERATOR_HSL_LUMINOSITY);
#endif
} else {
cairo_set_operator(ctx, CAIRO_OPERATOR_OVER);
}
Expand Down

0 comments on commit faec4ae

Please sign in to comment.