xxxxxxxxxx
32
function setup() {
createCanvas(500, 500);
}
function draw() {
background(255);
drawGrid();
noStroke();
fill(0);
circle(mouseX, mouseY, 15);
text("X = "+mouseX+" Y = "+ mouseY, mouseX-50, mouseY-20);
}
// ------------------------------
function drawGrid(){
stroke(150);
// vertical lines
line(100, 0, 100, height);
line(200, 0, 200, height);
line(300, 0, 300, height);
line(400, 0, 400, height);
// horizontal lines
line(0, 100, width, 100);
line(0, 200, width, 200);
line(0, 300, width, 300);
line(0, 400, width, 400);
}