# Any looping method to draw grids?

## Recommended Posts

Hi, I know that I can use 2 for loops to draw a 2 dimension grid line.

something like this:

1 1 1 1

1 1 1 1

1 1 1 1

1 1 1 1

But is there any way to draw a diamond shape grid line

something like this:

00100

01010

10101

01010

00100

Sorry that I can't describe what I meant exactly but is general a 45 degree rotation of a normal 2 dimensional grid.

Hope your get what I meant.

[font="Arial"]Thanks[/font]
```If @error = me Then \$sorry
Else
Do
\$clarifyMe
Until \$meClear
EndIF
MsgBox(0,"Special Message!","Special Thanks to " & \$allHadReplied,\$Forever)```

##### Share on other sites

There's prob. a few ways.

Depends what you're "drawing" to.

```0) Make all locations = 0
1) Find middle column (mc) of first row: DiamondRA[1,mc] = 1
2) For CurR = 2 to middle row (mr) do:
for CurC = mc-CurR to mc+CurR do:
If IsOdd(CurC) then DiamondRA[CurR, CurC] = 1

3) DiamondRA[LastR, mc] = 1
4) For CurR = LastR downto mr+1 do:
for CurC = mc-CurR to mc+CurR do:
If IsOdd(CurC) then DiamondRA[CurR, CurC] = 1```

This is just off the top of my head. Hope it's not all bunged up.

2); Go to next row, make points on each side of diamond point into acks

; Go to next row, make points on each side of diamond point into acks plus a point in between

; etc. to the middle

3)+4) do the same thing from the bottom up

PS All is contingent on boundaries of array; if odd in length or height, must adapt alg., etc.

J

Edited by jdickens

If I am too verbose, just say so. You don't need to run on and on.

## Create an account

Register a new account