Spiral matrix: Difference between revisions

Line 1,607:
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls, Windows}}
This code actually creates thea requiredmatrix in memory and stores values in the matrix, instead of just simulating one drawing the pattern. It can also create matrices of any size and the matrices don't have to be square. It works by creating a rectangle of the same size as the matrix,. thenIt enteringenters the values alongin the linesmatrix along circumference of the rectanglematrix. It then uses the Windows library routine "InflateRect" to decrease the size of the rectangle until the whole matrix is filled with spiraling values. Since a rectangle can be any size and doesn't have to be square, it works with any size matrix, including non-square matrices.
 
<syntaxhighlight lang="Delphi">
465

edits