# An uneven grid

Hello there,
I’ve got yet another question. I want to make a grid, kind of like this one: http://incompetech.com/graphpaper/moorish/
Pretty much squares surrounded by rectangles.

1.How would I go about drawing that?
2. Is it possible to determine the locations of certain objects on the graph once it’s made?

Thank you… Again.

Here’s some code that might help start you off. It draws the uneven grid.

Touch and drag on the grid to highlight the cell under your finger.

``````--# Main
displayMode(FULLSCREEN)

-- Use this function to perform your initial setup
function setup()
end

-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(239, 238, 235, 255)

-- This sets the line thickness
stroke(168, 190, 209, 255)
strokeWidth(2)
noSmooth()

local gridWidth = 40
local ratio = 4

local xSamp = WIDTH/gridWidth
local ySamp = HEIGHT/gridWidth

for x = 1,xSamp do
local xl = x * gridWidth
local xlo = xl + gridWidth/ratio
line( xl, 0, xl, HEIGHT )
line( xlo, 0, xlo, HEIGHT )
end

for y = 1,ySamp do
local yl = y * gridWidth
local ylo = yl + gridWidth/ratio
line( 0, yl, WIDTH, yl )
line( 0, ylo, WIDTH, ylo )
end

-- Get current grid location
local gridTouchX = math.floor( CurrentTouch.x / gridWidth )
local gridTouchY = math.floor( CurrentTouch.y / gridWidth )

-- Draw a rectangle at the current touch
noFill()
stroke(211, 92, 62, 255)

rect( gridTouchX * gridWidth,
gridTouchY * gridWidth, gridWidth, gridWidth )
end
``````