Popular recipes by Rick Muller http://code.activestate.com/recipes/users/1461790/2007-02-26T15:06:15-08:00ActiveState Code RecipesParseline: break a text line into formatted regions (Python) 2007-02-26T15:06:15-08:00Rick Mullerhttp://code.activestate.com/recipes/users/1461790/http://code.activestate.com/recipes/502260-parseline-break-a-text-line-into-formatted-regions/ <p style="color: grey"> Python recipe 502260 by <a href="/recipes/users/1461790/">Rick Muller</a> (<a href="/recipes/tags/text/">text</a>). </p> <p>Parseline breaks a line (actually a string) into python objects like strings, floats, ints, etc., based upon a short format string.</p> Use PIL to make a "contact sheet" montage of images (Python) 2005-05-02T15:28:49-07:00Rick Mullerhttp://code.activestate.com/recipes/users/1461790/http://code.activestate.com/recipes/412982-use-pil-to-make-a-contact-sheet-montage-of-images/ <p style="color: grey"> Python recipe 412982 by <a href="/recipes/users/1461790/">Rick Muller</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>The Python Imaging Library (PIL) makes many tasks easy in digital photography. This recipe shows how to make a "contact sheet" of images, a single image with thumbnails of many different pictures. It's limited in that it will only work with pictures of the same shape, but you can make some really fun images.</p> Open a GLUT window and draw a sphere using Python/OpenGL (Python) 2004-10-27T09:55:45-07:00Rick Mullerhttp://code.activestate.com/recipes/users/1461790/http://code.activestate.com/recipes/325391-open-a-glut-window-and-draw-a-sphere-using-pythono/ <p style="color: grey"> Python recipe 325391 by <a href="/recipes/users/1461790/">Rick Muller</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>This code snippet uses Python/OpenGL (<a href="http://pyopengl.sourceforge.net" rel="nofollow">http://pyopengl.sourceforge.net</a>) to open a window using GLUT, and draw a sphere into it. I've used this many times as the starting point for more complicated applications.</p> Draw SVG Images In Python (Python) 2004-10-30T08:43:06-07:00Rick Mullerhttp://code.activestate.com/recipes/users/1461790/http://code.activestate.com/recipes/325823-draw-svg-images-in-python/ <p style="color: grey"> Python recipe 325823 by <a href="/recipes/users/1461790/">Rick Muller</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>This script draws simple SVG images composed of circles, squares, lines, text, etc.</p> Matlab-like 'spy' and 'pcolor' functions (Python) 2005-03-02T15:23:38-08:00Rick Mullerhttp://code.activestate.com/recipes/users/1461790/http://code.activestate.com/recipes/390208-matlab-like-spy-and-pcolor-functions/ <p style="color: grey"> Python recipe 390208 by <a href="/recipes/users/1461790/">Rick Muller</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>I really like the 'spy' and 'pcolor' functions, which are useful in viewing matrices. 'spy' prints colored blocks for values that are above a threshold, and 'pcolor' prints out each element in a continuous range of colors. The attached is a little Python/PIL script that does these functions for Numpy arrays.</p> Manipulate simple polynomials in Python (Python) 2005-01-07T11:45:06-08:00Rick Mullerhttp://code.activestate.com/recipes/users/1461790/http://code.activestate.com/recipes/362193-manipulate-simple-polynomials-in-python/ <p style="color: grey"> Python recipe 362193 by <a href="/recipes/users/1461790/">Rick Muller</a> (<a href="/recipes/tags/graphics/">graphics</a>). Revision 2. </p> <p>This package does simple polynomial manipulation: adding, multiplying, taking to powers, evaluating at a value, taking integrals and derivatives. Nothing as sophisticated as Mathematica, but useful all the same. I find that I make lots of dumb errors in multiplying out polynomials by hand (when I don't have Mathematica at my disposal), and this little script helps prevent those errors.</p> Use wxPython/OpenGL to draw a sphere (Python) 2004-10-27T12:53:47-07:00Rick Mullerhttp://code.activestate.com/recipes/users/1461790/http://code.activestate.com/recipes/325392-use-wxpythonopengl-to-draw-a-sphere/ <p style="color: grey"> Python recipe 325392 by <a href="/recipes/users/1461790/">Rick Muller</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>A simple wxPython/OpenGL application to draw a sphere.</p> Wolfram-style cellular automata (Python) 2004-11-23T20:52:41-08:00Rick Mullerhttp://code.activestate.com/recipes/users/1461790/http://code.activestate.com/recipes/343386-wolfram-style-cellular-automata/ <p style="color: grey"> Python recipe 343386 by <a href="/recipes/users/1461790/">Rick Muller</a> (<a href="/recipes/tags/graphics/">graphics</a>). Revision 2. </p> <p>This is a little script that uses Python to generate the cellular automata that Wolfram discusses in his book "A New Kind of Science". The script uses the Python Imaging Library to render the output, but you could replace this with text or any other method of visualization.</p> Using code.InteractiveConsole to embed a Python shell in a user interface (Python) 2004-12-02T10:07:39-08:00Rick Mullerhttp://code.activestate.com/recipes/users/1461790/http://code.activestate.com/recipes/355319-using-codeinteractiveconsole-to-embed-a-python-she/ <p style="color: grey"> Python recipe 355319 by <a href="/recipes/users/1461790/">Rick Muller</a> (<a href="/recipes/tags/ui/">ui</a>). </p> <p>The code module provides the ability to write your own Python shell, which you can use to filter out input or output, and embed it in another application. This recipe shows how this module can be used.</p> Mandelbrot/Frame Binary Fractal Trees (Python) 2004-11-27T14:10:09-08:00Rick Mullerhttp://code.activestate.com/recipes/users/1461790/http://code.activestate.com/recipes/347736-mandelbrotframe-binary-fractal-trees/ <p style="color: grey"> Python recipe 347736 by <a href="/recipes/users/1461790/">Rick Muller</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>This little application generates Mandelbrot/Frame's fractal trees in Python (see <a href="http://www.math.union.edu/research/fractaltrees/" rel="nofollow">http://www.math.union.edu/research/fractaltrees/</a>). Given an iteration depth, a trunk length, and a branching angle, this algorithm generates the corresponding tree. PIL is used to draw the tree.</p>