簡體   English   中英

Draw2D設定位置

[英]Draw2D Set Position

我是這個庫的新手,似乎找不到任何有關如何調整畫布大小和位置的詳細信息。 希望這里有人可以以最佳方式指導我放置畫布

   $(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));
    });
}

“ gfx_holder”是您的HTML元素的ID。 您可以使用常規JavaScript設置寬度和高度。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM