chessboard.html


001| import tesserax as tess
002| import tesserax.layout as lay
003| 
004| def main ():
005|   filename = r'C:\Demo\HCC\Python'
006|   rows = 10
007|   cols = 10
008|   size = 50
009|   pad  = 20
010| 
011|   # Initialize canvas...
012|   with tess.Canvas() as canvas:
013| 
014|     # One big Column of rows...
015|     with lay.Column(gap=0):
016| 
017|       # Top Margin...
018|       tess.Rect(size, 30, fill=None, stroke=None)
019| 
020|       # Rows...
021|       for row in range(rows):
022|         with lay.Row(gap=0):
023| 
024|           # Left Margin...
025|           tess.Rect(50, size, fill=None, stroke=None)
026| 
027|           # Columns...
028|           for col in range(cols):
029|             color = '#dfdfdf' if (row+col) % 2 else '#ff7f7f'
030|             tess.Square(size, fill=color, stroke='black')
031| 
032|   # Fit the viewport to the shapes and render
033|   canvas.fit(padding=pad)
034|   canvas.save(filename)
035| 
036| if __name__ == '__main__':
037|   print()
038|   main()
039|   print()
040|