Denisolt / NightSky

A way to avoid paying 50 bucks by using some js to generate an image of the night sky at specific time and location. 🌑
Other
73 stars 22 forks source link

draw celestial grid? #2

Open anzgar01 opened 3 years ago

anzgar01 commented 3 years ago

Hi there, can anyone point me in the right direction what to do if I wanted to draw the celestial grid as well?

Thanks a lot!

randomdipesh commented 1 year ago

//draw grid

function drawGrid (context, gridSize, color) { context.lineWidth = 0.5; context.strokeStyle = color || "#CCC";

// Draw vertical grid lines
for (var x = 0; x <= context.canvas.width; x += gridSize) {
    context.beginPath();
    context.moveTo(x, 0);
    context.lineTo(x, context.canvas.height);
    context.stroke();
}

// Draw horizontal grid lines
for (var y = 0; y <= context.canvas.height; y += gridSize) {
    context.beginPath();
    context.moveTo(0, y);
    context.lineTo(context.canvas.width, y);
    context.stroke();
}

}