Skip to content
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

Adding Freehand with ClipPath to Object Group #6955

Closed
Neuroforge opened this issue Mar 25, 2021 · 7 comments · May be fixed by #7175
Closed

Adding Freehand with ClipPath to Object Group #6955

Neuroforge opened this issue Mar 25, 2021 · 7 comments · May be fixed by #7175

Comments

@Neuroforge
Copy link

Neuroforge commented Mar 25, 2021

Hello,

I am working with Fabricjs and i'd like to draw inside of a circle and have the path constrained to the circle. This includes the selection area of the group.

UPDATE:

Seem to have solved the first point

http://jsfiddle.net/42snph1d/14/

However, the selection are is too big. Anyway to reduce it so it is the side of the circle and not the path?

Is it possible to truncate the PATH to only include points inside the circle?


http://jsfiddle.net/42snph1d/12/

I am seeing weird artefacts when moving the object around.

  1. The freehand drawing can be seen in the canvas outside of the circle when moving
  2. The group selection is large, includes the entire freehand drawing. I'd like the selection area to only contain the circle.

Any obvious fixes here?

circle

Any advice would be appreciated.

@Neuroforge Neuroforge changed the title Adding Freehand to Object. Adding Freehand with ClipPath to Object Group Mar 25, 2021
@stale
Copy link

stale bot commented Apr 10, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label Apr 10, 2021
@asturur
Copy link
Member

asturur commented Apr 12, 2021

today there isn't. But is something we want to solve since long, together with clipPath blurryness.
The issue could be solve at multiple levels, but i think the easiest is when we draw the control box and controls.

If you do not need much editing you can still clone you circle + drawing to image with the proper method, cutting away transparent pixels.

If that would work for you i can try to write an example.
The object would become an image then, and wouldn't be a circle anymore.

@stale stale bot removed the stale Issue marked as stale by the stale bot label Apr 12, 2021
@ShaMan123
Copy link
Contributor

ShaMan123 commented Apr 21, 2021

I have solved this issue. It is related to progress made by #6994. I Thought I should PR this new functionality but wasn't sure it was needed

@ShaMan123
Copy link
Contributor

ShaMan123 commented Apr 21, 2021

My approach consists of creating a group that contains the circle and the path and a clip path identical to the circle. This way only the area of the circle will be visible. To make this work properly I have patched fabric.Group to calculate it's size according to the given object (circle in your case). This issue was exactly something I needed and I came by it now by chance.
@asturur are you interested?

@ShaMan123
Copy link
Contributor

ShaMan123 commented Apr 21, 2021

BTW I've patched the brush as well by applying a clip path to it so to create an effect that the brush draws only on the desired object

@ShaMan123
Copy link
Contributor

duplicate #5431

@asturur
Copy link
Member

asturur commented Apr 30, 2021

Yes is a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants