Browse Source

Added path preservation support to Context2d::{stroke,fill}()

v1.x
Tj Holowaychuk 14 years ago
parent
commit
9a6a86238e
  1. 24
      src/CanvasRenderingContext2d.cc
  2. 17
      test/public/tests.js

24
src/CanvasRenderingContext2d.cc

@ -1144,9 +1144,15 @@ Context2d::Arc(const Arguments &args) {
void
Context2d::fill(bool preserve) {
setSourceRGBA(state->fill);
hasShadow()
? shadow(cairo_fill)
: cairo_fill(_context);
if (preserve) {
hasShadow()
? shadow(cairo_fill_preserve)
: cairo_fill_preserve(_context);
} else {
hasShadow()
? shadow(cairo_fill)
: cairo_fill(_context);
}
}
/*
@ -1156,9 +1162,15 @@ Context2d::fill(bool preserve) {
void
Context2d::stroke(bool preserve) {
setSourceRGBA(state->stroke);
hasShadow()
? shadow(cairo_stroke)
: cairo_stroke(_context);
if (preserve) {
hasShadow()
? shadow(cairo_stroke_preserve)
: cairo_stroke_preserve(_context);
} else {
hasShadow()
? shadow(cairo_stroke)
: cairo_stroke(_context);
}
}
/*

17
test/public/tests.js

@ -1012,3 +1012,20 @@ tests['shadowBlur stroke()'] = function(ctx){
ctx.strokeRect(150,150,20,20);
};
tests['shadowBlur globalAlpha'] = function(ctx){
ctx.lineTo(0,0);
ctx.lineTo(50,0);
ctx.lineTo(50,150);
ctx.stroke();
ctx.lineWidth = 5;
ctx.globalAlpha = 0.3;
ctx.shadowColor = '#00c';
ctx.shadowBlur = 2;
ctx.shadowOffsetX = 8;
ctx.shadowOffsetY = 8;
ctx.lineTo(0,150);
ctx.stroke();
};
Loading…
Cancel
Save