<jupyter_start><jupyter_text>A grid of blocks whose colors ca be individually controlled  |   |  Parameters |  ---------- |  width : int |      Number of blocks wide to make the grid. |  height : int |      Number of blocks high to make the grid. |  fill : tuple of int, optional |      An optional initial color for the grid, defaults to black. |      Specified as a tuple of (red, green, blue). E.g.: (10, 234, 198) |  block_size : int, optional |      Length of the sides of grid blocks in pixels. One is the lower limit. |  lines_on : bool, optional |      Whether or not to display lines between blocks. |<jupyter_code>grid = BlockGrid(10, 10, fill=(123, 234, 123))
grid<jupyter_output><empty_output><jupyter_text>What is RGB - The RGB color model is an additive color model in which red, green and blue light are added together in various ways to reproduce a broad array of colors.<jupyter_code>from ipythonblocks import show_color, embed_colorpicker
show_color(12, 123, 234)<jupyter_output><empty_output><jupyter_text>Exercise 1: Try show_color(0,0,0) and show_color(255,255,255) We can pick out blocks from the grid. grid [x, y] will give us the block on row x and column y e.g. grid[0,0] will give us block on 0th row and 0th column.<jupyter_code>grid[0,0]  # You can also say grid[0,0].show()<jupyter_output><empty_output><jupyter_text>Lets change its color<jupyter_code>grid[0,0].red = 100
grid[0,0].green = 15
grid[0,0].blue = 15
grid[0,0].show()
grid<jupyter_output><empty_output><jupyter_text>Rows and Columns - what are these ?  lets find the x,y of the block we just colored.<jupyter_code>grid[0,0].row
grid[2,5].red = 200
grid[2,5].green = 20
grid[2,5].blue = 20
grid
grid[2,5].row
grid[2,5].col<jupyter_output><empty_output><jupyter_text>Exercise 2 - Change color of grid[5,10] and grid [9,9] - Look up http://htmlcolorcodes.com/color-picker/ and pick rgb values What does % or (modulo) operator do?<jupyter_code>6%2 # Divide 6 by 2 , quotient is 3 , remainder is 0 - modulo operator returns remainder<jupyter_output><empty_output><jupyter_text>Exercise 3 - Try 7%2<jupyter_code>for block in grid:
    if block.row % 2 == 0 and block.col % 3 == 0:
        block.red = 0
        block.green = 0
        block.blue = 0
grid<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11062141912736889, 'fraction_numerical': 0.04671661524900837, 'mean_word_length': 4.2304147465437785, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '572269', 'license': 'Apache-2.0', 'n_tokens_mistral': 836, 'n_tokens_neox': 765, 'n_words': 265, 'path': 'notebooks/python3/blocksandgrids.ipynb', 'repo_name': 'rsudhar/pykids', 'size': '2269'}