2013-04-24 2 views

답변

0

나는 jsfiddle에서 찾은 해결책을 생각해 냈지만 지금은 그 참조 링크를 찾을 수 없습니다. 방금 내 코드를 사용하여 해당 솔루션을 사용자 지정했습니다. 그 사람 덕분에. 여기 내 해결책이 있습니다. -

function draw_grid(grid_size) { 

    grid_size || (grid_size = 25); 
    currentCanvasWidth = canvas.getWidth(); 
    currentcanvasHeight = canvas.getHeight(); 


    // Drawing vertical lines 
    var x; 
    for (x = 0; x <= currentCanvasWidth; x += grid_size) { 
     this.grid_context.moveTo(x + 0.5, 0); 
     this.grid_context.lineTo(x + 0.5, currentCanvasHeight); 
    } 

    // Drawing horizontal lines 
    var y; 
    for (y = 0; y <= currentCanvasHeight; y += grid_size) { 
     this.grid_context.moveTo(0, y + 0.5); 
     this.grid_context.lineTo(currentCanvasWidth, y + 0.5); 
    } 

    grid_size = grid_size; 
    this.grid_context.strokeStyle = "black"; 
    this.grid_context.stroke(); 
} 

언젠가는 누군가가되기를 바랍니다.

관련 문제