{
"metadata": {
"name": "ipythonblocks_fun"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Playing with ipythonblocks
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more on `ipythonblocks` see the home page at [https://github.com/jiffyclub/ipythonblocks](https://github.com/jiffyclub/ipythonblocks)."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from ipythonblocks import BlockGrid"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import math"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"w = 100\n",
"h = 100\n",
"r = 35\n",
"\n",
"grid = BlockGrid(w, h, block_size=4)\n",
"\n",
"for block in grid:\n",
" val = math.fabs(math.sqrt((w / 2. - block.col) ** 2 + (h / 2. - block.row) ** 2) - r) ** 1.5 / r * 255\n",
" block.red = val\n",
" block.green = val\n",
" block.blue = val\n",
"\n",
"grid.show()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"