字面画布绘制区域大小

时间:2017-10-09 14:08:28

标签: javascript html canvas drawing paint

我正在使用Literally Canvas库。如何设置绘图区域大小?我试过这样但是它不起作用:

<body onload="initDraw()">
    <div class="my-drawing"></div>

    <script>
        function initDraw() {           
            $(document).ready(function () {
                var winHeight = $(window).height();
                var winWidth = $(window).width();

                var lc = LC.init(
                    document.getElementsByClassName('my-drawing')[0],
                    { imageURLPrefix: '/Content/lc-images' }
                );

                lc.imageSize(winWidth, winHeight); 

                lc.respondToSizeChange();
            });
        }
    </script>
</body>

1 个答案:

答案 0 :(得分:0)

像这样:

<script>

$(document).ready(function() {

    /* area for drawing */
    var imageSize = {width: 818, height: 515};

    //start literally canvas
    var lc = LC.init(
        document.getElementsByClassName('drawingapp')[0],
        {
            backgroundColor: 'whiteSmoke', 
            imageSize: imageSize /* apply or set the area */
        }
    );

});

</script>