-
-
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
Circle Object with Stroke Renders Misaligned on Canvas in Fabric.js 6.3.0 #10199
Comments
there is no json or working code, so no one can help. |
@asturur Please take a look, and I would appreciate it if you could provide a solution based on this. |
You come up with a size of 650 but is completely unclear why. To me is not 650 is a large number you don't provide the reason why you think it should fit in 650. |
As per the project requirements, I am generating a PDF that matches the dimensions of the canvas flyer, which in our tool is set to 650x650. To achieve this, I am using the design's JSON data to recreate the canvas, capturing a screenshot of the canvas using a third-party tool, and then creating the PDF from that screenshot. While the design on the canvas appears as expected, I am encountering some positioning issues when generating the PDF. |
You could have some zoom added to the canvas from your application, this zoom is not captured in the export. If you want your object to fit in an arbitrary size of 650by650 you have to zoom in or out till they perfectly fit. |
My canvas size is 650x650 with a zoom level of 100%, which corresponds to a zoom level of 1 in Fabric.js. When I add circles, one has both a stroke and a strokeWidth, another has a shadow, and a third has neither a stroke nor shadow. The design saves perfectly in my tool. However, when I render the design again using my code, I encounter a positioning issue, even though the canvas remains at 100% zoom, the same level as when I saved it. Additionally, our tool supports canvas sizes ranging from 50px to 5000px, with zoom levels between 0.1 and 3. Given this flexibility, I need a solution that resolves this issue without relying on the canvas's zoom level |
As i said before, this would work out of the box. The data imho has been clearly manipulated / edited incorrectly
width and height of 390 but a radius of 141.84300000000002 is wrong and won't work |
CheckList
Version
6.0.2
In What environments are you experiencing the problem?
Chrome
Node Version (if applicable)
16.14.0
Link To Reproduction
No
Steps To Reproduce
I am currently using Fabric.js version 6.3.0 in a normal HTML project. When loading and rendering a circle object created in Fabric.js 6.4.2 (via JSON) using the provided code snippet, I encounter an issue when the circle object has a shadow or stroke applied. Without shadow or stroke, the circle renders perfectly; however, when these styles are present, the circle does not render as expected.
In my code, I am passing the circle object data through fabric.util.enlivenObjects and creating a new canvas for rendering. Below is the core section of my code where the issue occurs:
`
let objectRender = [];
fabric.util.enlivenObjects(objectRender).then(async (enlivenedObjects) => {
await enlivenedObjects.forEach(async function (obj, index) {
if (obj.type == 'circle') {
obj.endAngle = 360;
}
});
`
Expected Behavior
As per image i want output like above
Actual Behavior
Actual output is like above image so how can i achieve my excepted output.
I would appreciate any guidance or recommendations on how to resolve the issue of misaligned rendering when the circle object has shadow or stroke applied, particularly when working between different Fabric.js versions.
Error Message & Stack Trace
No response
The text was updated successfully, but these errors were encountered: