<tfoot id='uGnvn'></tfoot>

    • <bdo id='uGnvn'></bdo><ul id='uGnvn'></ul>
    <legend id='uGnvn'><style id='uGnvn'><dir id='uGnvn'><q id='uGnvn'></q></dir></style></legend>

    <small id='uGnvn'></small><noframes id='uGnvn'>

  1. <i id='uGnvn'><tr id='uGnvn'><dt id='uGnvn'><q id='uGnvn'><span id='uGnvn'><b id='uGnvn'><form id='uGnvn'><ins id='uGnvn'></ins><ul id='uGnvn'></ul><sub id='uGnvn'></sub></form><legend id='uGnvn'></legend><bdo id='uGnvn'><pre id='uGnvn'><center id='uGnvn'></center></pre></bdo></b><th id='uGnvn'></th></span></q></dt></tr></i><div id='uGnvn'><tfoot id='uGnvn'></tfoot><dl id='uGnvn'><fieldset id='uGnvn'></fieldset></dl></div>

      使用 fabricjs 模拟自由绘图

      时间:2023-06-20

          <bdo id='crvNI'></bdo><ul id='crvNI'></ul>

              <tbody id='crvNI'></tbody>
            <i id='crvNI'><tr id='crvNI'><dt id='crvNI'><q id='crvNI'><span id='crvNI'><b id='crvNI'><form id='crvNI'><ins id='crvNI'></ins><ul id='crvNI'></ul><sub id='crvNI'></sub></form><legend id='crvNI'></legend><bdo id='crvNI'><pre id='crvNI'><center id='crvNI'></center></pre></bdo></b><th id='crvNI'></th></span></q></dt></tr></i><div id='crvNI'><tfoot id='crvNI'></tfoot><dl id='crvNI'><fieldset id='crvNI'></fieldset></dl></div>

                <legend id='crvNI'><style id='crvNI'><dir id='crvNI'><q id='crvNI'></q></dir></style></legend>
              • <small id='crvNI'></small><noframes id='crvNI'>

              • <tfoot id='crvNI'></tfoot>

              • 本文介绍了使用 fabricjs 模拟自由绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在开发具有白板的应用程序.白板应该像 idroo.com 一样工作.一个用户正在绘制一些其他用户应该能够在他的浏览器上实时看到的东西.我使用fabricjs 作为画布包装器,它有我需要的一切.但我无法在画布上模拟自由绘图.我将鼠标位置和画笔选项发送到远程客户端,并尝试通过触发鼠标移动事件来呈现它们.但它不起作用.如果有人有类似的问题,你能帮忙吗?

                I am developing application which has whiteboard. Whiteboard should work like idroo.com. One user is drawing something another user should be able to see it on his browser in real time. I use fabricjs as canvas wrapper and it has everithing I need. But I can't emulate free drawing on canvas. I send mouse position and brush options to remote client and try to render them by firing mouse move events. But it don't work. If some body has simialiar problem can you please help?

                canvasContainer.on('mousemove', function (e) {      
                    var left = canvasContainer.offset().left;
                    var top = canvasContainer.offset().top;
                    var x = e.pageX - left;
                    var y = e.pageY - top;         
                    //Send data to remote browser by socket.io or signalr
                    //I need to draw on remote browser by these x and y coordinates.
                    updateCursor(_connections, x, y);
                });
                

                推荐答案

                你可以这样做:

                var brush = new fabric.PencilBrush(canvas);
                var points = [[10,10], [20,20], [25,70],[100,300]];
                
                brush.onMouseDown({x:points[0][0], y:points[0][1]});
                for(var i=1;i<points.length;i++) {
                  brush.onMouseMove({x:points[i][0], y:points[i][1]});
                }
                

                在此处查看插件:https://plnkr.co/edit/V1c1xkB29tgB2ha99CRQ?p=preview

                您可以简化计算 x 和坐标的代码,并像这样:

                You can simplify your code for calculating x and coordinates and do it like this:

                var point = canvas.getPointer(e);
                

                这篇关于使用 fabricjs 模拟自由绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Html 5 Canvas 完整箭头 下一篇:在 &lt;canvas&gt; 上将鼠标悬停在图像上进行缩放

                相关文章

                  1. <tfoot id='jbVVX'></tfoot>
                    • <bdo id='jbVVX'></bdo><ul id='jbVVX'></ul>
                    <i id='jbVVX'><tr id='jbVVX'><dt id='jbVVX'><q id='jbVVX'><span id='jbVVX'><b id='jbVVX'><form id='jbVVX'><ins id='jbVVX'></ins><ul id='jbVVX'></ul><sub id='jbVVX'></sub></form><legend id='jbVVX'></legend><bdo id='jbVVX'><pre id='jbVVX'><center id='jbVVX'></center></pre></bdo></b><th id='jbVVX'></th></span></q></dt></tr></i><div id='jbVVX'><tfoot id='jbVVX'></tfoot><dl id='jbVVX'><fieldset id='jbVVX'></fieldset></dl></div>
                    <legend id='jbVVX'><style id='jbVVX'><dir id='jbVVX'><q id='jbVVX'></q></dir></style></legend>
                  2. <small id='jbVVX'></small><noframes id='jbVVX'>