This is a migrated thread and some comments may be shown as answers.

Surface.clear() does'nt work with canvas type

3 Answers 12 Views
Drawing API
This is a migrated thread and some comments may be shown as answers.
Syleps
Top achievements
Rank 1
Veteran
Syleps asked on 16 Apr 2021, 10:10 AM

Hi,

if you take your example : https://docs.telerik.com/kendo-ui/knowledge-base/drawing-draw-signature-and-export-svg

and that we change the type of surface to "canvas" (var surface = draw.Surface.create($("#surface"),{type : "canvas"});)

the "clear" button doesn't work.

Regards

3 Answers, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 21 Apr 2021, 09:45 AM

Hello Syleps,

I will need a little bit more time to review the issue. I will get back to you once I have some information to share.

Thank you very much for your patience.

Regards,
Neli
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Syleps
Top achievements
Rank 1
Veteran
answered on 21 Apr 2021, 10:06 AM

Hi,

thank you. 

know that I found a workaround by adding :

        const ctx = myCanvas.getContext('2d');
        ctx.clearRect(0, 0, myCanvas.width, myCanvas.height);

before clear()

Regards


0
Neli
Telerik team
answered on 23 Apr 2021, 05:11 AM

Hello Syleps,

Thank you very much for your patience. Thank you also for sharing the solution you have found. I am sure it will be helpful to the other users in the Forum who have the same issue.

Another possible approach is to use the resize() method in order to clear the canvas:

$(".clear").click(function() {
    surface.clear();
    surface.resize();
});

Here you will find a Dojo example where this is demonstrated.

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Drawing API
Asked by
Syleps
Top achievements
Rank 1
Veteran
Answers by
Neli
Telerik team
Syleps
Top achievements
Rank 1
Veteran
Share this question
or