Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: coloring individual hexagons in a grid...
Replies: 4   Last Post: Sep 16, 2012 3:23 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Richard Palmer

Posts: 46
Registered: 7/31/06
Re: coloring individual hexagons in a grid...
Posted: Aug 31, 2012 4:02 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


Thanks Bob, However, I am trying to color the interior of the hexagons,
not the edges.

On Wed, Aug 29, 2012 at 11:26 PM, Bob Hanlon <hanlonr357@gmail.com> wrote:

> Hexagon[x_] :=
> Line[x + # & /@
> (Through[{Cos, Sin}[Pi #/3]] & /@
> Range[0, 6])]
>
> HexagonalGrid[nbrRows_, nbrColumns_,
> colorFunction_: Null] :=
> Module[{i, j},
> Table[{
> If[colorFunction === Null,
> Black,
> colorFunction[i, j]],
> Hexagon[
> {3/2 j, Sqrt[3] i + Mod[j, 2] Sqrt[3]/2}]}, {i, nbrRows}, {j,
> nbrColumns}]]
>
> With[{k = 3},
> Show[Graphics[
> HexagonalGrid[k, k]],
> AspectRatio -> Automatic]]
>
> With[{k = 3},
> Show[Graphics[
> HexagonalGrid[k, k, Hue[
> Rescale[#1 + #2, {2, 2 k}]] &],
> AspectRatio -> Automatic]]]
>




--
Richard Palmer

Home 941 412 8828
Cell 508 982-7266




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.