Fabric.js eraser issue canvas

Multi tool use
Multi tool use












9















I want to implement eraser in my web app using Fabric.js. Is there any way to implement eraser in Fabric.js? For example, such as in MS Paint?










share|improve this question





























    9















    I want to implement eraser in my web app using Fabric.js. Is there any way to implement eraser in Fabric.js? For example, such as in MS Paint?










    share|improve this question



























      9












      9








      9








      I want to implement eraser in my web app using Fabric.js. Is there any way to implement eraser in Fabric.js? For example, such as in MS Paint?










      share|improve this question
















      I want to implement eraser in my web app using Fabric.js. Is there any way to implement eraser in Fabric.js? For example, such as in MS Paint?







      canvas coffeescript html5-canvas fabricjs






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 22 '13 at 17:18









      kangax

      33.6k1078126




      33.6k1078126










      asked Oct 11 '13 at 5:44









      nAkhmedovnAkhmedov

      1,21632348




      1,21632348
























          2 Answers
          2






          active

          oldest

          votes


















          15














          There's no built-in eraser in Fabric and implementing is a bit difficult.



          The thing about Fabric is that everything is object-based and most of the things are also vector-based.



          Unlike with native canvas, we can't just erase some pixels on a global bitmap. We have entire object model underneath, and canvas output is a simple loop of all those objects rendered onto canvas.



          One way we could emulate eraser is perhaps by having some kind of overlay on top of canvas. And sort-of draw "erased" lines on it, giving illusion of underlying objects being wiped out.



          But there are still complications with this:




          • How would we serialize this layer (to JSON or to SVG)?

          • What if you erase half of previously-drawn path and then want to work with already erased shape? The shape itself needs to be modified; overlay wouldn't work.

          • Would eraser affect only shapes or also background color? What about background image?


          There's likely more issues that I didn't think of at the moment.






          share|improve this answer































            1














            I just wrote my eraser in Fabric, and I hope to be able answer also the questions made by @kangax.



            First, if you want to have a handwriting eraser, you should build an object like this:



            canvas.freeDrawingBrush = new fabric.PencilBrush(canvas);


            Then I slightly hacked the actual fabric library (v. 2.4.3) here:



            createPath: function(pathData) {
            var path = new fabric.Path(pathData, {
            fill: null,
            stroke: this.color,
            strokeWidth: this.width,
            strokeLineCap: this.strokeLineCap,
            strokeMiterLimit: this.strokeMiterLimit,
            strokeLineJoin: this.strokeLineJoin,
            strokeDashArray: this.strokeDashArray,
            // ADDED BY AZ (24 Nov 2018)
            globalCompositeOperation: this.globalCompositeOperation,
            id: this.id
            });


            Using globalCompositeOperation you can manage your canvas.freeDrawingBrush to draw a colored path (the color you wish, I choose red, but you can also choose the background color of your canvas) as this:



            canvas.isDrawingMode = 1;
            canvas.freeDrawingBrush.color = "red";
            canvas.freeDrawingBrush.width = 10;
            canvas.freeDrawingBrush.globalCompositeOperation = 'destination-out';
            canvas.freeDrawingBrush.id = 'erasure';
            ctx.beginPath(); // the context of canvas
            canvas.renderAll();


            So, when you move your mouse onto the canvas, you'll see a red path. When you move up the mouse, the path is finally created and the gCO is applied, erasing everything down the red path.



            Well, if you want to save the canvas, I prefer to use the canvas.toSVG() function (it's great for retina screens if you're able to manage it).
            So, to save the canvas as SVG you just need this line canvas.toSVG() and you can store the result somewhere.
            When you want to restore the canvas, you should manage also the 'erasure' id, so you can use my restore function:



            function restoreSketch(imageSVG) {
            fabric.loadSVGFromString(imageSVG, function (objects, options) {
            $.each(objects, function (index, value) {
            if (value.id && value.id == 'erasure') {
            value.set({
            globalCompositeOperation: 'destination-out'
            }); //set gCO for value
            }
            });
            var obj = fabric.util.groupSVGElements(objects, options);
            canvas.add(obj).renderAll();
            });


            I hope to be useful for everybody having headaches with Fabric.js



            EDIT: as suggested by @Benni the lines related to the erasure can be displaced. If you want to fix them onto the canvas, you might slightly change the code using lockMovementX and lockMovementY.
            So, in the fabric.js lib, after



            globalCompositeOperation: this.globalCompositeOperation,


            add:



            lockMovementX: this.lockMovementX,
            lockMovementY: this.lockMovementY,


            Then, in your code, after canvas.freeDrawingBrush.id = 'erasure'; add:



            canvas.freeDrawingBrush.lockMovementX = true;
            canvas.freeDrawingBrush.lockMovementY = true;





            share|improve this answer


























            • That is a great idea, however if you use selection with Fabric.js, then it is possible to select these transparent lines and move them around. Any idea how to solve this problem?

              – Benni
              Jan 30 at 17:51






            • 1





              ok I edited the previous answer

              – Zappescu
              Jan 31 at 18:16











            • Good idea, however that does not work well, if you like to support selection of the other objects. The movement of the transparent lines is now locked (lockScaling and lockRotation should be added). If you move any non transparent object, the transparent objects stays at the last position and that is confusing for the user. I have also thought about moving the transparent lines or if there is a way to redraw the objects..

              – Benni
              Jan 31 at 20:29











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19311038%2ffabric-js-eraser-issue-canvas%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            15














            There's no built-in eraser in Fabric and implementing is a bit difficult.



            The thing about Fabric is that everything is object-based and most of the things are also vector-based.



            Unlike with native canvas, we can't just erase some pixels on a global bitmap. We have entire object model underneath, and canvas output is a simple loop of all those objects rendered onto canvas.



            One way we could emulate eraser is perhaps by having some kind of overlay on top of canvas. And sort-of draw "erased" lines on it, giving illusion of underlying objects being wiped out.



            But there are still complications with this:




            • How would we serialize this layer (to JSON or to SVG)?

            • What if you erase half of previously-drawn path and then want to work with already erased shape? The shape itself needs to be modified; overlay wouldn't work.

            • Would eraser affect only shapes or also background color? What about background image?


            There's likely more issues that I didn't think of at the moment.






            share|improve this answer




























              15














              There's no built-in eraser in Fabric and implementing is a bit difficult.



              The thing about Fabric is that everything is object-based and most of the things are also vector-based.



              Unlike with native canvas, we can't just erase some pixels on a global bitmap. We have entire object model underneath, and canvas output is a simple loop of all those objects rendered onto canvas.



              One way we could emulate eraser is perhaps by having some kind of overlay on top of canvas. And sort-of draw "erased" lines on it, giving illusion of underlying objects being wiped out.



              But there are still complications with this:




              • How would we serialize this layer (to JSON or to SVG)?

              • What if you erase half of previously-drawn path and then want to work with already erased shape? The shape itself needs to be modified; overlay wouldn't work.

              • Would eraser affect only shapes or also background color? What about background image?


              There's likely more issues that I didn't think of at the moment.






              share|improve this answer


























                15












                15








                15







                There's no built-in eraser in Fabric and implementing is a bit difficult.



                The thing about Fabric is that everything is object-based and most of the things are also vector-based.



                Unlike with native canvas, we can't just erase some pixels on a global bitmap. We have entire object model underneath, and canvas output is a simple loop of all those objects rendered onto canvas.



                One way we could emulate eraser is perhaps by having some kind of overlay on top of canvas. And sort-of draw "erased" lines on it, giving illusion of underlying objects being wiped out.



                But there are still complications with this:




                • How would we serialize this layer (to JSON or to SVG)?

                • What if you erase half of previously-drawn path and then want to work with already erased shape? The shape itself needs to be modified; overlay wouldn't work.

                • Would eraser affect only shapes or also background color? What about background image?


                There's likely more issues that I didn't think of at the moment.






                share|improve this answer













                There's no built-in eraser in Fabric and implementing is a bit difficult.



                The thing about Fabric is that everything is object-based and most of the things are also vector-based.



                Unlike with native canvas, we can't just erase some pixels on a global bitmap. We have entire object model underneath, and canvas output is a simple loop of all those objects rendered onto canvas.



                One way we could emulate eraser is perhaps by having some kind of overlay on top of canvas. And sort-of draw "erased" lines on it, giving illusion of underlying objects being wiped out.



                But there are still complications with this:




                • How would we serialize this layer (to JSON or to SVG)?

                • What if you erase half of previously-drawn path and then want to work with already erased shape? The shape itself needs to be modified; overlay wouldn't work.

                • Would eraser affect only shapes or also background color? What about background image?


                There's likely more issues that I didn't think of at the moment.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 22 '13 at 17:23









                kangaxkangax

                33.6k1078126




                33.6k1078126

























                    1














                    I just wrote my eraser in Fabric, and I hope to be able answer also the questions made by @kangax.



                    First, if you want to have a handwriting eraser, you should build an object like this:



                    canvas.freeDrawingBrush = new fabric.PencilBrush(canvas);


                    Then I slightly hacked the actual fabric library (v. 2.4.3) here:



                    createPath: function(pathData) {
                    var path = new fabric.Path(pathData, {
                    fill: null,
                    stroke: this.color,
                    strokeWidth: this.width,
                    strokeLineCap: this.strokeLineCap,
                    strokeMiterLimit: this.strokeMiterLimit,
                    strokeLineJoin: this.strokeLineJoin,
                    strokeDashArray: this.strokeDashArray,
                    // ADDED BY AZ (24 Nov 2018)
                    globalCompositeOperation: this.globalCompositeOperation,
                    id: this.id
                    });


                    Using globalCompositeOperation you can manage your canvas.freeDrawingBrush to draw a colored path (the color you wish, I choose red, but you can also choose the background color of your canvas) as this:



                    canvas.isDrawingMode = 1;
                    canvas.freeDrawingBrush.color = "red";
                    canvas.freeDrawingBrush.width = 10;
                    canvas.freeDrawingBrush.globalCompositeOperation = 'destination-out';
                    canvas.freeDrawingBrush.id = 'erasure';
                    ctx.beginPath(); // the context of canvas
                    canvas.renderAll();


                    So, when you move your mouse onto the canvas, you'll see a red path. When you move up the mouse, the path is finally created and the gCO is applied, erasing everything down the red path.



                    Well, if you want to save the canvas, I prefer to use the canvas.toSVG() function (it's great for retina screens if you're able to manage it).
                    So, to save the canvas as SVG you just need this line canvas.toSVG() and you can store the result somewhere.
                    When you want to restore the canvas, you should manage also the 'erasure' id, so you can use my restore function:



                    function restoreSketch(imageSVG) {
                    fabric.loadSVGFromString(imageSVG, function (objects, options) {
                    $.each(objects, function (index, value) {
                    if (value.id && value.id == 'erasure') {
                    value.set({
                    globalCompositeOperation: 'destination-out'
                    }); //set gCO for value
                    }
                    });
                    var obj = fabric.util.groupSVGElements(objects, options);
                    canvas.add(obj).renderAll();
                    });


                    I hope to be useful for everybody having headaches with Fabric.js



                    EDIT: as suggested by @Benni the lines related to the erasure can be displaced. If you want to fix them onto the canvas, you might slightly change the code using lockMovementX and lockMovementY.
                    So, in the fabric.js lib, after



                    globalCompositeOperation: this.globalCompositeOperation,


                    add:



                    lockMovementX: this.lockMovementX,
                    lockMovementY: this.lockMovementY,


                    Then, in your code, after canvas.freeDrawingBrush.id = 'erasure'; add:



                    canvas.freeDrawingBrush.lockMovementX = true;
                    canvas.freeDrawingBrush.lockMovementY = true;





                    share|improve this answer


























                    • That is a great idea, however if you use selection with Fabric.js, then it is possible to select these transparent lines and move them around. Any idea how to solve this problem?

                      – Benni
                      Jan 30 at 17:51






                    • 1





                      ok I edited the previous answer

                      – Zappescu
                      Jan 31 at 18:16











                    • Good idea, however that does not work well, if you like to support selection of the other objects. The movement of the transparent lines is now locked (lockScaling and lockRotation should be added). If you move any non transparent object, the transparent objects stays at the last position and that is confusing for the user. I have also thought about moving the transparent lines or if there is a way to redraw the objects..

                      – Benni
                      Jan 31 at 20:29
















                    1














                    I just wrote my eraser in Fabric, and I hope to be able answer also the questions made by @kangax.



                    First, if you want to have a handwriting eraser, you should build an object like this:



                    canvas.freeDrawingBrush = new fabric.PencilBrush(canvas);


                    Then I slightly hacked the actual fabric library (v. 2.4.3) here:



                    createPath: function(pathData) {
                    var path = new fabric.Path(pathData, {
                    fill: null,
                    stroke: this.color,
                    strokeWidth: this.width,
                    strokeLineCap: this.strokeLineCap,
                    strokeMiterLimit: this.strokeMiterLimit,
                    strokeLineJoin: this.strokeLineJoin,
                    strokeDashArray: this.strokeDashArray,
                    // ADDED BY AZ (24 Nov 2018)
                    globalCompositeOperation: this.globalCompositeOperation,
                    id: this.id
                    });


                    Using globalCompositeOperation you can manage your canvas.freeDrawingBrush to draw a colored path (the color you wish, I choose red, but you can also choose the background color of your canvas) as this:



                    canvas.isDrawingMode = 1;
                    canvas.freeDrawingBrush.color = "red";
                    canvas.freeDrawingBrush.width = 10;
                    canvas.freeDrawingBrush.globalCompositeOperation = 'destination-out';
                    canvas.freeDrawingBrush.id = 'erasure';
                    ctx.beginPath(); // the context of canvas
                    canvas.renderAll();


                    So, when you move your mouse onto the canvas, you'll see a red path. When you move up the mouse, the path is finally created and the gCO is applied, erasing everything down the red path.



                    Well, if you want to save the canvas, I prefer to use the canvas.toSVG() function (it's great for retina screens if you're able to manage it).
                    So, to save the canvas as SVG you just need this line canvas.toSVG() and you can store the result somewhere.
                    When you want to restore the canvas, you should manage also the 'erasure' id, so you can use my restore function:



                    function restoreSketch(imageSVG) {
                    fabric.loadSVGFromString(imageSVG, function (objects, options) {
                    $.each(objects, function (index, value) {
                    if (value.id && value.id == 'erasure') {
                    value.set({
                    globalCompositeOperation: 'destination-out'
                    }); //set gCO for value
                    }
                    });
                    var obj = fabric.util.groupSVGElements(objects, options);
                    canvas.add(obj).renderAll();
                    });


                    I hope to be useful for everybody having headaches with Fabric.js



                    EDIT: as suggested by @Benni the lines related to the erasure can be displaced. If you want to fix them onto the canvas, you might slightly change the code using lockMovementX and lockMovementY.
                    So, in the fabric.js lib, after



                    globalCompositeOperation: this.globalCompositeOperation,


                    add:



                    lockMovementX: this.lockMovementX,
                    lockMovementY: this.lockMovementY,


                    Then, in your code, after canvas.freeDrawingBrush.id = 'erasure'; add:



                    canvas.freeDrawingBrush.lockMovementX = true;
                    canvas.freeDrawingBrush.lockMovementY = true;





                    share|improve this answer


























                    • That is a great idea, however if you use selection with Fabric.js, then it is possible to select these transparent lines and move them around. Any idea how to solve this problem?

                      – Benni
                      Jan 30 at 17:51






                    • 1





                      ok I edited the previous answer

                      – Zappescu
                      Jan 31 at 18:16











                    • Good idea, however that does not work well, if you like to support selection of the other objects. The movement of the transparent lines is now locked (lockScaling and lockRotation should be added). If you move any non transparent object, the transparent objects stays at the last position and that is confusing for the user. I have also thought about moving the transparent lines or if there is a way to redraw the objects..

                      – Benni
                      Jan 31 at 20:29














                    1












                    1








                    1







                    I just wrote my eraser in Fabric, and I hope to be able answer also the questions made by @kangax.



                    First, if you want to have a handwriting eraser, you should build an object like this:



                    canvas.freeDrawingBrush = new fabric.PencilBrush(canvas);


                    Then I slightly hacked the actual fabric library (v. 2.4.3) here:



                    createPath: function(pathData) {
                    var path = new fabric.Path(pathData, {
                    fill: null,
                    stroke: this.color,
                    strokeWidth: this.width,
                    strokeLineCap: this.strokeLineCap,
                    strokeMiterLimit: this.strokeMiterLimit,
                    strokeLineJoin: this.strokeLineJoin,
                    strokeDashArray: this.strokeDashArray,
                    // ADDED BY AZ (24 Nov 2018)
                    globalCompositeOperation: this.globalCompositeOperation,
                    id: this.id
                    });


                    Using globalCompositeOperation you can manage your canvas.freeDrawingBrush to draw a colored path (the color you wish, I choose red, but you can also choose the background color of your canvas) as this:



                    canvas.isDrawingMode = 1;
                    canvas.freeDrawingBrush.color = "red";
                    canvas.freeDrawingBrush.width = 10;
                    canvas.freeDrawingBrush.globalCompositeOperation = 'destination-out';
                    canvas.freeDrawingBrush.id = 'erasure';
                    ctx.beginPath(); // the context of canvas
                    canvas.renderAll();


                    So, when you move your mouse onto the canvas, you'll see a red path. When you move up the mouse, the path is finally created and the gCO is applied, erasing everything down the red path.



                    Well, if you want to save the canvas, I prefer to use the canvas.toSVG() function (it's great for retina screens if you're able to manage it).
                    So, to save the canvas as SVG you just need this line canvas.toSVG() and you can store the result somewhere.
                    When you want to restore the canvas, you should manage also the 'erasure' id, so you can use my restore function:



                    function restoreSketch(imageSVG) {
                    fabric.loadSVGFromString(imageSVG, function (objects, options) {
                    $.each(objects, function (index, value) {
                    if (value.id && value.id == 'erasure') {
                    value.set({
                    globalCompositeOperation: 'destination-out'
                    }); //set gCO for value
                    }
                    });
                    var obj = fabric.util.groupSVGElements(objects, options);
                    canvas.add(obj).renderAll();
                    });


                    I hope to be useful for everybody having headaches with Fabric.js



                    EDIT: as suggested by @Benni the lines related to the erasure can be displaced. If you want to fix them onto the canvas, you might slightly change the code using lockMovementX and lockMovementY.
                    So, in the fabric.js lib, after



                    globalCompositeOperation: this.globalCompositeOperation,


                    add:



                    lockMovementX: this.lockMovementX,
                    lockMovementY: this.lockMovementY,


                    Then, in your code, after canvas.freeDrawingBrush.id = 'erasure'; add:



                    canvas.freeDrawingBrush.lockMovementX = true;
                    canvas.freeDrawingBrush.lockMovementY = true;





                    share|improve this answer















                    I just wrote my eraser in Fabric, and I hope to be able answer also the questions made by @kangax.



                    First, if you want to have a handwriting eraser, you should build an object like this:



                    canvas.freeDrawingBrush = new fabric.PencilBrush(canvas);


                    Then I slightly hacked the actual fabric library (v. 2.4.3) here:



                    createPath: function(pathData) {
                    var path = new fabric.Path(pathData, {
                    fill: null,
                    stroke: this.color,
                    strokeWidth: this.width,
                    strokeLineCap: this.strokeLineCap,
                    strokeMiterLimit: this.strokeMiterLimit,
                    strokeLineJoin: this.strokeLineJoin,
                    strokeDashArray: this.strokeDashArray,
                    // ADDED BY AZ (24 Nov 2018)
                    globalCompositeOperation: this.globalCompositeOperation,
                    id: this.id
                    });


                    Using globalCompositeOperation you can manage your canvas.freeDrawingBrush to draw a colored path (the color you wish, I choose red, but you can also choose the background color of your canvas) as this:



                    canvas.isDrawingMode = 1;
                    canvas.freeDrawingBrush.color = "red";
                    canvas.freeDrawingBrush.width = 10;
                    canvas.freeDrawingBrush.globalCompositeOperation = 'destination-out';
                    canvas.freeDrawingBrush.id = 'erasure';
                    ctx.beginPath(); // the context of canvas
                    canvas.renderAll();


                    So, when you move your mouse onto the canvas, you'll see a red path. When you move up the mouse, the path is finally created and the gCO is applied, erasing everything down the red path.



                    Well, if you want to save the canvas, I prefer to use the canvas.toSVG() function (it's great for retina screens if you're able to manage it).
                    So, to save the canvas as SVG you just need this line canvas.toSVG() and you can store the result somewhere.
                    When you want to restore the canvas, you should manage also the 'erasure' id, so you can use my restore function:



                    function restoreSketch(imageSVG) {
                    fabric.loadSVGFromString(imageSVG, function (objects, options) {
                    $.each(objects, function (index, value) {
                    if (value.id && value.id == 'erasure') {
                    value.set({
                    globalCompositeOperation: 'destination-out'
                    }); //set gCO for value
                    }
                    });
                    var obj = fabric.util.groupSVGElements(objects, options);
                    canvas.add(obj).renderAll();
                    });


                    I hope to be useful for everybody having headaches with Fabric.js



                    EDIT: as suggested by @Benni the lines related to the erasure can be displaced. If you want to fix them onto the canvas, you might slightly change the code using lockMovementX and lockMovementY.
                    So, in the fabric.js lib, after



                    globalCompositeOperation: this.globalCompositeOperation,


                    add:



                    lockMovementX: this.lockMovementX,
                    lockMovementY: this.lockMovementY,


                    Then, in your code, after canvas.freeDrawingBrush.id = 'erasure'; add:



                    canvas.freeDrawingBrush.lockMovementX = true;
                    canvas.freeDrawingBrush.lockMovementY = true;






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jan 31 at 18:20

























                    answered Nov 25 '18 at 18:00









                    ZappescuZappescu

                    1,1442724




                    1,1442724













                    • That is a great idea, however if you use selection with Fabric.js, then it is possible to select these transparent lines and move them around. Any idea how to solve this problem?

                      – Benni
                      Jan 30 at 17:51






                    • 1





                      ok I edited the previous answer

                      – Zappescu
                      Jan 31 at 18:16











                    • Good idea, however that does not work well, if you like to support selection of the other objects. The movement of the transparent lines is now locked (lockScaling and lockRotation should be added). If you move any non transparent object, the transparent objects stays at the last position and that is confusing for the user. I have also thought about moving the transparent lines or if there is a way to redraw the objects..

                      – Benni
                      Jan 31 at 20:29



















                    • That is a great idea, however if you use selection with Fabric.js, then it is possible to select these transparent lines and move them around. Any idea how to solve this problem?

                      – Benni
                      Jan 30 at 17:51






                    • 1





                      ok I edited the previous answer

                      – Zappescu
                      Jan 31 at 18:16











                    • Good idea, however that does not work well, if you like to support selection of the other objects. The movement of the transparent lines is now locked (lockScaling and lockRotation should be added). If you move any non transparent object, the transparent objects stays at the last position and that is confusing for the user. I have also thought about moving the transparent lines or if there is a way to redraw the objects..

                      – Benni
                      Jan 31 at 20:29

















                    That is a great idea, however if you use selection with Fabric.js, then it is possible to select these transparent lines and move them around. Any idea how to solve this problem?

                    – Benni
                    Jan 30 at 17:51





                    That is a great idea, however if you use selection with Fabric.js, then it is possible to select these transparent lines and move them around. Any idea how to solve this problem?

                    – Benni
                    Jan 30 at 17:51




                    1




                    1





                    ok I edited the previous answer

                    – Zappescu
                    Jan 31 at 18:16





                    ok I edited the previous answer

                    – Zappescu
                    Jan 31 at 18:16













                    Good idea, however that does not work well, if you like to support selection of the other objects. The movement of the transparent lines is now locked (lockScaling and lockRotation should be added). If you move any non transparent object, the transparent objects stays at the last position and that is confusing for the user. I have also thought about moving the transparent lines or if there is a way to redraw the objects..

                    – Benni
                    Jan 31 at 20:29





                    Good idea, however that does not work well, if you like to support selection of the other objects. The movement of the transparent lines is now locked (lockScaling and lockRotation should be added). If you move any non transparent object, the transparent objects stays at the last position and that is confusing for the user. I have also thought about moving the transparent lines or if there is a way to redraw the objects..

                    – Benni
                    Jan 31 at 20:29


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19311038%2ffabric-js-eraser-issue-canvas%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    U5BOgGHq,bk,EZuLBP3jm5 88joGLpxTW0 FPHW3yu,2ABC8Hqs9N,xt,y,7
                    WcK,f91W4w5Ql 8CQfRKbFFme r9Ft6AMUa4,qf,XW1lE6bZPWvlu

                    Popular posts from this blog

                    Wiesbaden

                    Dieringhausen

                    Marschland