Honeycombs: Difference between revisions

Line 11:
=={{header|Icon}} and {{header|Unicon}}==
[[File:HoneyComb unicon 4x5.PNG|thumb|right|4x5 Honeycomb in progress]]
The configuration of the honeycomb can be changed from the command line (height and width in cells as well as the length of the side of one cell). Window dimensions are calculated. The character set used to label cells expands for larger grids. The completed grid is saved as a GIF.
 
There is no hexagonal widget in the Icon Graphics library so a custom widget was developed. No attempt was made to make this widget like the VIB or VIB2 widgets.
 
The HexWidgetData record carries around alot of data about each widget including drawing coordinates, label, a routine to know if it's been selected and helper data, and coordinates for drawing neighboring cells (down and upper/lower right).
 
Label selection is straight forward. Mouse selection first determines if x,y is within the widgets rectangular outer bounds. The x,y point is then reflected into the north west quadrant of the cell and an abbreviated cross-product (x and y will always be 0) is used to tell if the point is within the widgets inner bounds.
<lang Icon>link printf
 
Line 73 ⟶ 80:
WriteImage(sprintf("%s-%d.gif",title,&now)) # save file
Font(fine) # tell how to quit
DrawString(wb,wh-wmsg,"LeftRight click to exit")
until Event() == &rpress
close(&window)
end
Line 84 ⟶ 91:
x := integer(0 <= ax) | runerr(205,ax) # ensure whole numbers
y := integer(0 <= ay) | runerr(205,ay)
u := integer(1 <= u) | runerr(205,u) # 1 is minimal if ridiculous
h := integer(sqrt(3./4) * (w := 2 * u)) # h,w
W := HexWidgetData(s,u,w,h, # string, side, width and height
Anonymous user