Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.13k stars 1.17k forks source link

Shadow is rendering inversed #724

Open keanass opened 8 years ago

keanass commented 8 years ago

Shadow is rendering inversed on latest version of canvas, any one know about this issue.

LinusU commented 8 years ago

Which was the last version it worked for you?

keanass commented 8 years ago

1.3.2 and upper,shadow of the scaled objects is not taking the angle of rotation.

LinusU commented 8 years ago

Probably #669, @inssein any ideas?

keanass commented 8 years ago

i tested all the versions no solution

keanass commented 8 years ago

i need just to calculate the ofsets x,y to rotate the shadow i have allready the angle, any idea

keanass commented 8 years ago

here is the solution for hwo want to export svg or png of canvas with rotated objects has shadow : var pOffset = fabric.util.rotatePoint(new fabric.Point(object.shadow.offsetX, object.shadow.offsetY), new fabric.Point(0, 0), fabric.util.degreesToRadians(360-object.angle)); then you get the new offsets : pOffset .x and pOffset .y

inssein commented 8 years ago

Sorry I was on vacation. @keanass is there still a node-canvas bug? You mentioned that it happened on all versions of node-canvas.

saberjsd commented 3 years ago

Hi, I may have the same problem.

// in browser CanvasRenderingContext2D
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 20;
ctx.drawImage(img,100,100);
// ctx.getTransform() = [0,1,-1,0,0,0]
// this ctx is rotate 90deg, and the shadow is just on bottom.
// in node canvas CanvasRenderingContext2D
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 20;
ctx.drawImage(img,100,100);
// ctx.currentTransform = [0,1,-1,0,0,0]
// this ctx is rotate 90deg, but the shadow is just on left!!!

Why don't they draw the same?