2013-10-01 40 views
2

我正在嘗試使用導航欄將網站製作爲paper.js中的4個圓圈。但是,使用resize選項時,canvas元素會佔據整個頁面。我使用了http://paperjs.org/tutorials/getting-started/working-with-paper-js/上給出的示例,我使用twitter bootstrap作爲其他內容。我使用col-md-12作爲包含畫布的div。我嘗試了make canvas as wide and as high as parent上給出的解決方案,但它不起作用。如何使用引導程序在Paper.js中設置canvas的view.viewSize

任何幫助?

回答

4

可以使用Javacript實現它:

$(window).resize(resizeAndRedrawCanvas); 

function resizeAndRedrawCanvas() 
{ 
    var desiredWidth = w; // For instance: $(window).width(); 
    var desiredHeight = h; // For instance $('#canvasContainer').height(); 

    canvas.width = desiredWidth; 
    canvas.height = desiredHeight 

    view.viewSize = new Size(desiredWidth, desiredHeight); 
    view.draw(); 
} 
相關問題