{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import time\n",
      "from numpy import pi, cos, sin, linspace, roll, zeros_like\n",
      "from bokeh.plotting import *\n",
      "from bokeh.objects import Glyph, Range1d"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "N = 50 + 1\n",
      "r_base = 8\n",
      "theta = linspace(0, 2*pi, N)\n",
      "r_x = linspace(0, 6*pi, N-1)\n",
      "rmin = r_base - cos(r_x) - 1\n",
      "rmax = r_base + sin(r_x) + 1\n",
      "colors = [\"FFFFCC\", \"#C7E9B4\", \"#7FCDBB\", \"#41B6C4\", \"#2C7FB8\", \"#253494\", \"#2C7FB8\", \"#41B6C4\", \"#7FCDBB\", \"#C7E9B4\"] * 5\n",
      "cx = cy = zeros_like(rmin)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "output_notebook(name=\"default\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "annular_wedge(\n",
      "    cx, cy, rmin, rmax, theta[:-1], theta[1:],\n",
      "    x_range = Range1d(start=-11, end=11),\n",
      "    y_range = Range1d(start=-11, end=11),\n",
      "    inner_radius_units=\"data\",\n",
      "    outer_radius_units=\"data\",\n",
      "    fill_color = colors,\n",
      "    line_color=\"black\",\n",
      "    tools=\"pan,wheel_zoom,box_zoom,reset,resize\"\n",
      ")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "renderer = [r for r in curplot().renderers if isinstance(r, Glyph)][0]\n",
      "ds = renderer.data_source\n",
      "show()\n",
      "while True:\n",
      "    for i in linspace(-2*pi, 2*pi, 50):\n",
      "        rmin = ds.data[\"inner_radius\"]\n",
      "        rmin = roll(rmin, 1)\n",
      "        ds.data[\"inner_radius\"] = rmin\n",
      "        rmax = ds.data[\"outer_radius\"]\n",
      "        rmax = roll(rmax, -1)\n",
      "        ds.data[\"outer_radius\"] = rmax\n",
      "        ds._dirty = True\n",
      "        session().store_obj(ds)\n",
      "        time.sleep(.10)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}
