-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Shadow Rendering Issue in Fabric.js 6.3.0 for Transparent Circle, Rect #10142
Comments
that is not how shadow for the canvas works sadly and there isn't a performing fix that makes sense. That would also delete anything that is under the shape with the shape itself. |
@yashChapaniOB can you tell me how you do in v6 the rounded rectangle for middles handlers ? |
You have to write your own control render function. Please look at the standard control.render function and write your own with a rounded rect. |
@asturur don't find control.render, can you give a sample or the file for search in ? |
@asturur ok I write this : `Control.prototype.render = function(ctx, left, top, styleOverride, fabricObject)
It's working, but how to know if it draw the top left corner ? or middle right ? |
Please read this carefully Then create a render function for each type of rendering you need, then assign it to the correct control. |
CheckList
Description
In Fabric.js version 6.3.0, when applying a shadow to a transparent circle,Rect the shadow appears inside the circle,rect as well, instead of being limited to the outer area of the circle,Rect. The desired behavior is for the shadow to be rendered outside the circle's or Rect's boundary, without affecting the inner transparent area.
Current Behavior
Currently, when a shadow is applied to a Rect or Circle, the shadow is visible within the object's boundary, which includes the transparent areas. This behavior deviates from the expected result, where the shadow should be projected outside the shape's edge, leaving the inner transparent regions unaffected.
Current State
var option = {};
option['objectCaching'] = true;
option['isLocked'] = false;
option['element_type'] = "basicShape";
let ctx = this.canvas.getContext('2d');
const shadow = new Shadow({
affectStroke: false
blur:0
color:"#000000ff",
includeDefaultValues:true,
nonScaling:false,
offsetX:50,
offsetY:50,
});
var rect = new Rect({
angle: 0,
fill: #FFDE59
borderColor: '#0069FF',
borderScaleFactor: 1.5,
centeredScaling: false,
centeredRotation: true,
cornerSize: 15,
cornerColor: '#0069FF',
cornerStyle: 'circle',
shadow: shadow,
lockScalingFlip: true,
isLocked: false,
visible: true,
stroke: "#ffffffff"
selectionDashArray: [],
clipPath: undefined,
excludeFromExport: false,
strokeWidth: 0,
transparentCorners: false,
rx: 0,
ry:0,
_controlsVisibility: {
tl: true,
tr: true,
br: true,
bl: true,
ml: true,
mt: true,
mr: true,
mb: true,
mtr: true
},
type: 'rect',
element_type: 'basicShape',
...option
});
this.canvas.add(rect);
this.canvas.renderAll();
Expected Behavior
The shadow should be rendered outside the Rect or Circle boundaries, not within the shape's transparent inner area.
Additional Context
No response
The text was updated successfully, but these errors were encountered: