Spiral matrix: Difference between revisions

m
Line 1,607:
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls, Windows}}
This code actually creates a matrix in memory and stores values in the matrix, instead of just simulating one by 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. It enters the values in the matrix along circumference of the matrix. 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