MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Drawing Rectangular Grid

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20226] Re: [mg20198] Drawing Rectangular Grid
  • From: BobHanlon at aol.com
  • Date: Fri, 8 Oct 1999 18:30:09 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Wilson,

This modifies the AspectRatio on my first reply to adjust to varying grid 
sizes.
_____________________________________________

grid[{rows_Integer, cols_Integer}, disks_List] := 
    Module[{j, k, diskRadius = .3}, 
      Show[Graphics[
          Join[Table[{Hue[Mod[j + k, 2]/2], 
                Rectangle[{k - 1, j - 1}, {k, j}]}, {j, rows}, {k, cols}], 
            Disk[{#[[1]] - 1/2, #[[2]] - 1/2}, diskRadius] & /@ disks], 
          AspectRatio -> rows/cols]]];

filled = {{1, 3}, {4, 6}, {8, 8}};

grid[{8, 8}, filled];

Bob Hanlon

In a message dated 10/5/1999 8:10:21 AM, flip at aznet.net writes:

>I was hoping someone here could help.  I am writing some code for a
>Cellular Automata Simulator.
>
>I would like to have a function that I can give the following
>information to:
>
>Grid[size_of_grid, matrix_of_cells_to_fill]
>
>This function will draw a n x m rectangular grid = size (for example
>size = {2,2} for a 2 x 2 grid).
>
>I then will pass an array of the cells to be filled.  For example
>{{1,1},{2,2}}.  It could also be {{1,1},{1,2},{2,1},{2,2}}, in which
>case the whole grid will have filled cells.
>
>The Grid function will then return a Rectangular Grid with the cells
>(1,1) and (2,2), which are the diagonal cells filled in as either black
>cells or, better yet, as filled in circles that are smaller in size than
>the square grid cell size. (Little circles enclosed within the grid
>cells).
>
>Can someone help me with this function (I don't think that such a thing
>would be difficult for an experienced Mathematica user, but one never knows).
>


  • Prev by Date: Replacing Part of a Matrix
  • Next by Date: Re: Surface of Revolution
  • Previous by thread: Re: Drawing Rectangular Grid
  • Next by thread: Subscript Variable