Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11570 > unrolled thread
| Started by | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| First post | 2012-08-31 08:02 +0000 |
| Last post | 2012-09-16 07:23 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: coloring individual hexagons in a grid... Bob Hanlon <hanlonr357@gmail.com> - 2012-08-31 08:02 +0000
Re: coloring individual hexagons in a grid... paulsalomon27@gmail.com - 2012-09-16 07:23 +0000
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2012-08-31 08:02 +0000 |
| Subject | Re: coloring individual hexagons in a grid... |
| Message-ID | <k1pr2n$k17$1@smc.vnet.net> |
Then make Hexagon a Polygon rather than a Line.
Hexagon[x_] :=
Polygon[x + # & /@ (Through[{Cos, Sin}[Pi #/3]] & /@ Range[0, 6])]
HexagonalGrid[nbrRows_, nbrColumns_, colorFunction_: Null] :=
Module[{i, j},
Table[{If[colorFunction === Null, Lighter[Gray, .9], 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[{EdgeForm[Thick], HexagonalGrid[k, k]}],
AspectRatio -> Automatic]]
With[{k = 3},
Show[Graphics[{EdgeForm[Thick],
HexagonalGrid[k, k, Hue[Rescale[#1 + #2, {2, 2 k}]] &]},
AspectRatio -> Automatic]]]
On Thu, Aug 30, 2012 at 12:34 PM, Richard Palmer <rhpalmer@gmail.com> wrote:
> 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
>
>
[toc] | [next] | [standalone]
| From | paulsalomon27@gmail.com |
|---|---|
| Date | 2012-09-16 07:23 +0000 |
| Message-ID | <k33up9$quh$1@smc.vnet.net> |
| In reply to | #11570 |
Working on some mathematical art, and this code is EXACTLY what I needed! Thank you so much!!! The tricky part is figuring out how to express the recursive RGBColor function I want to build. :) Paul bit.ly/mathmunch
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web