【问题标题】:Getting Ink Strokes in MyScript在 MyScript 中获取墨迹
【发布时间】:2016-11-04 22:48:24
【问题描述】:

我正在使用 MyScript,我注意到对于 Web API(在此处查找示例:http://doc.myscript.com/MyScriptCloud/3.1.0/myscript-cloud/examples.html),需要“笔画”类型以及描述笔画的所有坐标。

我想知道我应该使用什么软件来生成这些笔画,或者我如何自己编程?官方文档中没有任何内容。

感谢您的宝贵时间。

【问题讨论】:

    标签: image-processing web


    【解决方案1】:

    服务器期望的笔画类型是一个带有x、y属性的json对象,包含两个整数数组。这些值表示在设备触摸屏上书写时的 x,y 坐标用户输入。您可以收集并添加时间戳作为 JSON 笔画类型结构的可选“t”属性。

    作为第一个选项,您可以使用我们的 web 组件:myscript-math-web、myscript-text-web 甚至 MyScriptJS 来管理用户墨水捕获和画布中的渲染。

    你也可以自己抓取用户的笔迹,这种情况下我们推荐你使用(jquery PEP)[https://github.com/jquery/PEP](Pointer Event Polyfill)来帮助你管理用户触屏事件,即指针事件。

    您必须监听 pointerdown、pointermove 和 pointerup 事件。一旦发生此类事件,以这种方式将事件坐标添加到您的结构中,例如:

    var myStroke; document.querySelector('#myCanvasId').addEventListener('pointerdown', function (e) { e.preventDefault(); 我的行程= {x:[],y:[],t:[]}; mystroke.x.push(e.clientX); mystroke.y.push(e.clientY); mystroke.t.push(e.timestamp) },假);

    document.querySelector('#myCanvasId').addEventListener('pointermove', function (e) { e.preventDefault(); mystroke.x.push(e.clientX); mystroke.y.push(e.clientY); mystroke.t.push(e.timestamp) },假);

    document.querySelector('#myCanvasId').addEventListener('pointerup', function (e) { e.preventDefault(); mystroke.x.push(e.clientX); mystroke.y.push(e.clientY); mystroke.t.push(e.timestamp)

                        // Send your stroke to the server
                        mystroke = {};
        }, false);
    

    如果您需要更详细的解释,可以查看this video。 10:40 上有关数字墨水捕获的详细信息。

    【讨论】:

      猜你喜欢
      • 2011-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-12
      • 1970-01-01
      • 2018-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多