Newbie's question: how do you create a chessboard in Squ

Tue Apr 28 15:09:23 UTC 1998

```Try this goodie from the KSC archive.  Once installed, use it to generate a
array of relative Rectangles (origins and corners are points with coordinate
values between 0.0 and 1.0)

Add it to the Rectangle class.  This was originally written by Ken Auer (kwa)
while at KSC.

subDivideBy: aPoint
"kwa -- 19 September 1989, Answer a collection of rectangles which
divide the receiver evenly into aPoint x columns and aPoint y rows.  Answer the
new rectangles left to right then down.  Yes, this method could be much
shorter, but I tried to minimize duplications of arithmetic for efficiency."
"KSC Extension"
"(0 at 0 corner: 100 at 100) subDivideBy: 4 at 2"
"(0.0 at 0.0 corner: 1.0 at 1.0) subDivideBy: 3 at 1"   "<----- use something
like this to generate relative rectangles for subview layouts"
"commented out asInteger below to support rectangles defined by floats - ssa
11/13/97 14:36"

| rows columns eachWidth eachHeight subRegions rowTop baseIndex myLeft
rowBottom columnLeft columnRight |
columns _ aPoint x.
rows _ aPoint y.
eachWidth _ (self width asFloat / columns asFloat) "asInteger".
eachHeight _ (self height asFloat / rows asFloat) "asInteger".
subRegions _ Array new: columns * rows.
rowTop _ self top.
baseIndex _ 0.
myLeft _ self left.
1 to: rows do: [:rowNumber |
rowBottom _ rowTop + eachHeight.
columnLeft _ myLeft.
columnRight _ columnLeft + eachWidth.
1 to: columns do: [:columnNumber |
subRegions
at: baseIndex + columnNumber
put: (self species origin: columnLeft @ rowTop
corner: columnRight @ rowBottom).
columnLeft _ columnRight.
columnRight _ columnRight + eachWidth].
rowTop _ rowBottom.
rowBottom _ rowBottom + eachHeight.
baseIndex _ baseIndex + columns].
^subRegions

Sam S. Adams, Distinguished Engineer, IBM Network Computing Software Division
tie line 444-0736, outside 919-254-0736, email: ssadams at us.ibm.com
<<Hebrews 11:6, Proverbs 3:5-6, Romans 1:16-17, I Corinthians 1:10>>

```