首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Draw2D设置位置

Draw2D设置位置
EN

Stack Overflow用户
提问于 2014-05-12 22:08:08
回答 1查看 456关注 0票数 0

我是这个库的新手,似乎找不到任何关于如何调整画布大小和位置的详细信息。希望这里有人能指导我以最好的方式定位画布

代码语言:javascript
复制
   $(window).load(function () {


    // create the canvas for the user interaction
    //
    var canvas = new draw2d.Canvas("gfx_holder");

    // unmarshal the JSON document into the canvas
    // (load)
    var reader = new draw2d.io.json.Reader();
    reader.unmarshal(canvas, jsonDocument);

    // display the JSON document in the preview DIV
    //
    displayJSON(canvas);

    // add an event listener to the Canvas for change notifications.
    // We just dump the current canvas document into the DIV
    //
    canvas.getCommandStack().addEventListener(function (e) {
        if (e.isPostChangeEvent()) {
            displayJSON(canvas);
        }
    });
});

function displayJSON(canvas) {
    var writer = new draw2d.io.json.Writer();
    writer.marshal(canvas, function (json) {
        $("#json").text(JSON.stringify(json, null, 2));
    });
}
EN

回答 1

Stack Overflow用户

发布于 2014-09-10 05:37:10

"gfx_holder“是您的HTML元素的id。您可以使用常规JavaScript设置宽度和高度。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23611282

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档