Re: Drawing a honeycomb
- From: "John B. Matthews" <nospam@xxxxxxxxxxxxxx>
- Date: Mon, 06 Apr 2009 19:43:02 -0400
In article
<f581fd74-7a37-47ed-8d35-677d1c33b905@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
MikeB <MPBrede@xxxxxxxxx> wrote:
On Apr 6, 1:55 pm, Roedy Green <see_webs...@xxxxxxxxxxxxxxxxxxxx>[...]
wrote:
On Mon, 6 Apr 2009 11:29:41 -0700 (PDT), MikeB <MPBr...@xxxxxxxxx>
wrote, quoted or indirectly quoted someone who said :
I want to create a pane that, instead of a table of rows and columns,
have a honeycomb appearance, in other words an array of hexagonal
cells. I need to put information inside each cell, but I'm even stuck
at how to construct the borders of the cells. Ideally, the borders
should be sizable so that the user can adjus tthe size (and by
implication, the number of cells that will appear in the pane, or when
he resizes the pane.
You might have a start athttp://mindprod.com/products.html#SCREWS
It draws a hexagonal screw head.
A hexagon is defined as a line connecting vertices of the 6 rotations
of the angle pi/3 radians = 60 degrees where it intersects the circle.
Basically you convert polar to Cartesian co-ordinates.
Seehttp://mindprod.com/jgloss/coordinates.htmlhttp://mindprod.com/jgloss/pol
ar.htmlhttp://mindprod.com/jgloss/radian.html
Tackle this in stages.
1. draw a hexagon on a Canvas of JPanel.
2. draw a row of 4 hexagons
3. draw two rows of 4 meshing hexagons.
4. draw a grid of n x m hexagons.
5. draw a grid of hexagons with text on them.
6. resize the panel making all the hexagons grow
7. resize the panel adding hexagons.
8. resize the panel allowing both kinds of growth. How will you
specify it? sliders? Simply dragging the panel bigger will not do.
9. don't draw cells that don't fit 100 in the panel.
10. sex it up with some edge effects and subtle colour variations.
Search the web for some honeycomb images to get some ideas.
Roedy, Thanks a million. Just what I needed.
For step one, I recall that turtle graphics made it especially easy to
draw regular polygons, as there's a simple formula for the interior
angle:
<http://en.wikipedia.org/wiki/Regular_polygon#Angles>
I'd be surprised if there weren't a Java implementation.
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
.
- References:
- Drawing a honeycomb
- From: MikeB
- Re: Drawing a honeycomb
- From: Roedy Green
- Re: Drawing a honeycomb
- From: MikeB
- Drawing a honeycomb
- Prev by Date: Re: Drawing a honeycomb
- Next by Date: Re: NEVER MIND
- Previous by thread: Re: Drawing a honeycomb
- Next by thread: Re: Drawing a honeycomb
- Index(es):
Relevant Pages
|