<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 模拟自由绘图

      Emulate free drawing with fabricjs(使用 fabricjs 模拟自由绘图)

          <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 模拟自由绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How does object-fit work with canvas element?(对象适合如何与画布元素一起使用?)
                How to make rooftext effect and valley text effect in HTML5 (or Fabric.js)(如何在 HTML5(或 Fabric.js)中制作屋顶文字效果和山谷文字效果)
                Draw border around nontransparent part of image on canvas(在画布上的图像不透明部分周围绘制边框)
                dragging and resizing an image on html5 canvas(在 html5 画布上拖动图像并调整其大小)
                What#39;s the difference between a boolean as primitive and a boolean as property of an object?(作为原始对象的布尔值和作为对象属性的布尔值有什么区别?)
                I want to do animation of an object along a particular path(我想沿特定路径对对象进行动画处理)
                      <tbody id='jbVVX'></tbody>

                      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>
                        • <small id='jbVVX'></small><noframes id='jbVVX'>