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

chore(TS): migrate Eraser #8499

Closed
wants to merge 299 commits into from
Closed

chore(TS): migrate Eraser #8499

wants to merge 299 commits into from

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Dec 8, 2022

Motivation

Description

Migrate eraser and refactor to a module.
Adapt fabric entities so there is no mutation done (the mixin used to mutate the prototypes of Object, Group, Canvas)
Can be regarded as Eraser v3, see v2 #7470 for reference

Changes

  • comply EraserBrush to brush pattern
  • perf(): doesn't need to do a full redraw of path each frame/step
  • perf(): optimize needsFullRender - move alpha checking to PencilBrush and descendants not including eraser (I think we should try masking PencilBrush, same as the eraser does, but with fillRect of color, that will make redrawing the entire path redundant in case of opacity, am I right?)
  • perf(PencilBrush): fixed straight line used to redraw until mouse up regardless of the straight line state
  • fix(): erasing + straight line
  • feat(): alpha erasing
  • fix(): clipPath, changed rendering logic so that first the brush draws over top context, then it is masked and then it is used to clip the main context. Makes fix(EraserBrush): visual trace while erasing #7991 erasing trace/artifact in free drawing mode #7984 obsolete and won't fix and enhances perf
  • feat(): updating, eraser will subscribe to canvas rendering and update its pattern
  • fix(): utilize renderCanvas to render pattern correctly (was missing out canvas#clipPath)

Gist

In Action

Edit fabric-nextjs-sandbox (forked)

fabric.js.sandbox.-.Google.Chrome.2022-12-11.16-55-56_Trim.mp4

With clip path

fabric.js.sandbox.-.Google.Chrome.2022-12-11.16-49-33_Trim.mp4

commit 82c8918
Merge: f6669ab eb25d2b
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Fri Jun 10 22:01:36 2022 +0300

    Merge branch 'master' into pr/7175

commit f6669ab
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu May 12 10:06:51 2022 +0300

    Update .eslintrc.json

commit 0e4b9ef
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu May 12 10:01:03 2022 +0300

    Revert "Update .eslintrc.json"

    This reverts commit b52caa0.

commit b52caa0
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu May 12 09:53:19 2022 +0300

    Update .eslintrc.json

commit 082b063
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu May 12 09:30:35 2022 +0300

    Revert whitespace

    This reverts whitespace commited by 3f0f328.

commit 3f0f328
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu May 12 09:20:58 2022 +0300

    fix(): `absolutePositioned`

commit 3954fca
Merge: 60b5829 06de045
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Sun May 1 20:06:30 2022 +0300

    Merge branch 'master' into pr/7175

commit 60b5829
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Tue Apr 26 15:10:35 2022 +0300

    Update base_brush.class.js

commit 126514b
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Tue Apr 26 15:03:46 2022 +0300

    async test

commit 2d4aef7
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Tue Apr 26 14:57:23 2022 +0300

    lint

commit c36649f
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Tue Apr 26 14:50:36 2022 +0300

    rename: BaseBrush `render` <-> `_render`

    now conforms with Object

commit fddbae7
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Tue Apr 26 14:39:52 2022 +0300

    async

commit a8c1818
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Tue Apr 26 14:36:57 2022 +0300

    async

commit 8e20486
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Tue Apr 26 14:14:49 2022 +0300

    update code to master

commit d8eb923
Merge: f927143 4b3f9a3
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Tue Apr 26 13:47:08 2022 +0300

    Merge branch 'master' into pr/7175

commit f927143
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Feb 17 13:33:56 2022 +0200

    Update base_brush.class.js

commit 35c1364
Merge: 2442eed 70943e7
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Feb 17 13:27:07 2022 +0200

    Merge remote-tracking branch 'upstream/master' into brush-clip-path

commit 2442eed
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Mon Jan 17 14:27:29 2022 +0200

    Update pencil_brush.class.js

commit c2c856e
Merge: 85a6317 56f0629
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Mon Jan 17 14:22:26 2022 +0200

    Merge remote-tracking branch 'upstream/master' into brush-clip-path

commit 85a6317
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Sun Jan 16 15:47:58 2022 +0200

    Update base_brush.class.js

commit eef5936
Merge: 368dd71 a32be8a
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Sun Jan 16 15:43:46 2022 +0200

    Merge remote-tracking branch 'upstream/master' into brush-clip-path

commit 368dd71
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Fri Jul 2 07:38:00 2021 +0300

    Update eraser_brush.mixin.js

commit 1ebccf4
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 22:55:38 2021 +0300

    Update base_brush.class.js

commit 5747e02
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 22:46:55 2021 +0300

    fix rendering overlay with clip path

commit a3eb5d7
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 22:02:56 2021 +0300

    Update CHANGELOG.md

commit 8fe3e37
Merge: 251a5df 3b99a2d
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 22:01:12 2021 +0300

    Merge remote-tracking branch 'upstream/master' into brush-clip-path

commit 251a5df
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 21:59:14 2021 +0300

    revert dist

commit ceaf13d
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 21:50:39 2021 +0300

    lint

commit 5680f1f
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 21:48:54 2021 +0300

    support clipping eraser brush

    \

commit add527c
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 19:16:20 2021 +0300

    Update eraser_brush.mixin.js

commit 8b30537
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 19:13:11 2021 +0300

    fix(absolutePositioned)

commit 798199d
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 15:54:37 2021 +0300

    support `inverted` property

commit 9fea119
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 15:52:58 2021 +0300

    handle `absolutePositioned` case

commit 2640b2e
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 15:25:29 2021 +0300

    BREAKING: rename `render` to `renderAll`

    To align with this PR

commit 24489c4
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 15:00:50 2021 +0300

    Update CHANGELOG.md

commit 97ee528
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 14:54:05 2021 +0300

    lint

commit 99ff886
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 14:33:57 2021 +0300

    JSDOC

commit fc92fad
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 13:54:59 2021 +0300

    Update pencil_brush.class.js

commit 07fc81e
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 13:45:29 2021 +0300

    addClipPathToResult

    expose `_addClipPathToResult`
    If there's a clip path set on the brush it is applied to the brush result

commit 3cb75e4
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 13:31:50 2021 +0300

    draw clipPath when adding a brush segment

commit a824e91
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 08:25:41 2021 +0300

    BREAKING CHANGE

    renamed `render` to `renderChuck`
    `render` method now renders all the spray to align with all the brushes

commit cc5374d
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 08:24:37 2021 +0300

    Update pencil_brush.class.js

commit b551683
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 08:24:31 2021 +0300

    Update circle_brush.class.js

commit 373a450
Author: ShaMan123 <shacharnen@gmail.com>
Date:   Thu Jul 1 08:23:56 2021 +0300

    Update base_brush.class.js
BREAKING CHANGE: stop adding brush result to canvas, dep path:created, before:path:created
@kyun
Copy link

kyun commented Jun 29, 2023

@ShaMan123 Is this PR still working?

@ShaMan123
Copy link
Contributor Author

We need to merge it
Not sure when

@chrisp018
Copy link

Hi @ShaMan123, may we know this pr still on progress? do you know when it will be merged 🙇

@ShaMan123
Copy link
Contributor Author

I do not know
But it should
It is good to go, just needs to update from master

@JeremyMees
Copy link

JeremyMees commented Nov 13, 2023

@ShaMan123
Do you have idea now for when this is going to be added? I really don't wont to downgrade to version 5 😬
I hope this get's added soon because i really need it.

@ShaMan123
Copy link
Contributor Author

@asturur

@ShaMan123
Copy link
Contributor Author

I see this needs porting.
The diff is in a bad state

@ShaMan123
Copy link
Contributor Author

closing in favor of https://github.com/ShaMan123/erase2d

@ShaMan123 ShaMan123 closed this Mar 17, 2024
@ShaMan123 ShaMan123 deleted the ts-eraser branch March 17, 2024 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants