Browse Source

Merge branch 'shadow-transform' into shadow-blur

v1.x
Andy Wood 10 years ago
parent
commit
d5a1ce927f
  1. 6
      src/CanvasRenderingContext2d.cc
  2. 32
      test/public/tests.js

6
src/CanvasRenderingContext2d.cc

@ -349,11 +349,15 @@ Context2d::shadow(void (fn)(cairo_t *cr)) {
cairo_path_t *path = cairo_copy_path_flat(_context);
cairo_save(_context);
// Offset
// Offset (always unaffected by current transform)
cairo_matrix_t current_matrix;
cairo_get_matrix(_context, &current_matrix);
cairo_identity_matrix(_context);
cairo_translate(
_context
, state->shadowOffsetX
, state->shadowOffsetY);
cairo_transform(_context, &current_matrix);
// Apply shadow
cairo_push_group(_context);

32
test/public/tests.js

@ -1327,6 +1327,38 @@ tests['shadowOffset{X,Y} negative'] = function(ctx){
ctx.fillRect(150,150,20,20);
};
tests['shadowOffset{X,Y} transform'] = function(ctx){
ctx.translate(100, 0);
ctx.scale(.75,.75);
ctx.rotate(Math.PI/4);
ctx.fillRect(150,10,20,20);
ctx.lineTo(20,5);
ctx.lineTo(100,5);
ctx.stroke();
ctx.shadowColor = '#c00';
ctx.shadowBlur = 5;
ctx.shadowOffsetX = 10;
ctx.shadowOffsetY = 10;
ctx.fillRect(20,20,100,100);
ctx.beginPath();
ctx.lineTo(20,150);
ctx.lineTo(100,150);
ctx.stroke();
ctx.shadowBlur = 0;
ctx.beginPath();
ctx.lineTo(20,180);
ctx.lineTo(100,180);
ctx.stroke();
ctx.fillRect(150,150,20,20);
};
tests['shadowBlur values'] = function(ctx){
ctx.fillRect(150,10,20,20);

Loading…
Cancel
Save