Most viewed recipes tagged "graphics"http://code.activestate.com/recipes/tags/graphics/views/2016-01-27T22:22:01-08:00ActiveState Code RecipesOpen 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> PIL and Tkinter to display images. (Python) 2007-06-20T19:25:41-07:00Noah Spurrierhttp://code.activestate.com/recipes/users/103276/http://code.activestate.com/recipes/521918-pil-and-tkinter-to-display-images/ <p style="color: grey"> Python recipe 521918 by <a href="/recipes/users/103276/">Noah Spurrier</a> (<a href="/recipes/tags/graphics/">graphics</a>). Revision 3. </p> <p>Using PIL and Tkinter you can easily display images in a window.</p> Watermark with PIL (Python) 2005-01-12T11:07:01-08:00Shane Hathawayhttp://code.activestate.com/recipes/users/2257010/http://code.activestate.com/recipes/362879-watermark-with-pil/ <p style="color: grey"> Python recipe 362879 by <a href="/recipes/users/2257010/">Shane Hathaway</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>Apply a watermark to an image using the Python Imaging Library. Supports color, tiling, scaling, and opacity reduction.</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> Povray for python (Python) 2003-06-13T21:22:18-07:00Simon Burtonhttp://code.activestate.com/recipes/users/860809/http://code.activestate.com/recipes/205451-povray-for-python/ <p style="color: grey"> Python recipe 205451 by <a href="/recipes/users/860809/">Simon Burton</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>Here is a relatively simple framework for making povray files from your favourite programming language, python. It's good for creating structured/mathematical scenes and animations.</p> HTML colors to/from RGB tuples (Python) 2004-01-23T07:25:22-08:00Paul Winklerhttp://code.activestate.com/recipes/users/135731/http://code.activestate.com/recipes/266466-html-colors-tofrom-rgb-tuples/ <p style="color: grey"> Python recipe 266466 by <a href="/recipes/users/135731/">Paul Winkler</a> (<a href="/recipes/tags/graphics/">graphics</a>). Revision 2. </p> <p>You have colors in a number of formats (html-style #RRGGBB, rgb-tuples (r, g, b), and PIL-style integers). You want to convert between formats. It's pretty easy to do, but also pretty easy to forget; hence, this recipe.</p> <p>Just for kicks, we'll extract an RGB tuple from an image file at the end.</p> Human verification test (captcha) (Python) 2005-09-21T20:52:45-07:00Robert McDermotthttp://code.activestate.com/recipes/users/786815/http://code.activestate.com/recipes/440588-human-verification-test-captcha/ <p style="color: grey"> Python recipe 440588 by <a href="/recipes/users/786815/">Robert McDermott</a> (<a href="/recipes/tags/graphics/">graphics</a>). Revision 3. </p> <p>The gen_captcha function generates an image containing text that’s easy for a human to read, but difficult for a computer. This allows you create a test to tell humans and computers apart. (requires PIL)</p> Random Maze Generator (Python) 2012-12-14T09:09:22-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578356-random-maze-generator/ <p style="color: grey"> Python recipe 578356 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/ai/">ai</a>, <a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/pil/">pil</a>). Revision 2. </p> <p>Random maze generator using depth-first search.</p> <p>It starts the maze path from a random cell and there is no exit defined but actually any 2 cells on the path (white cells) can be assigned to be entry and exit locations. (I could just add code to randomly select 2 white cells and change their colors to something else but I thought it looks better this way.)</p> Drop shadows with PIL (Python) 2006-03-06T03:26:54-08:00Kevin Schluffhttp://code.activestate.com/recipes/users/1496147/http://code.activestate.com/recipes/474116-drop-shadows-with-pil/ <p style="color: grey"> Python recipe 474116 by <a href="/recipes/users/1496147/">Kevin Schluff</a> (<a href="/recipes/tags/graphics/">graphics</a>). Revision 2. </p> <p>This recipe demonstrates the use of the Python Imaging Library to apply a gaussian blur drop shadow to an image.</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> EAN Bar code image generator (Python) 2005-06-18T04:07:13-07:00remi inconnuhttp://code.activestate.com/recipes/users/832244/http://code.activestate.com/recipes/426069-ean-bar-code-image-generator/ <p style="color: grey"> Python recipe 426069 by <a href="/recipes/users/832244/">remi inconnu</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>This class generate EAN bar code, it required PIL (python imaging library) installed.</p> <p>If the code has not checksum (12 digits), it added automatically.</p> <p>Create bar code sample : from EANBarCode import EanBarCode bar = EanBarCode() bar.getImage("9782212110708",50,"gif")</p> Convert Image Format (Python) 2003-02-16T02:10:03-08:00Doug Blandinghttp://code.activestate.com/recipes/users/984954/http://code.activestate.com/recipes/180801-convert-image-format/ <p style="color: grey"> Python recipe 180801 by <a href="/recipes/users/984954/">Doug Blanding</a> (<a href="/recipes/tags/graphics/">graphics</a>). Revision 4. </p> <p>Simple GUI to allow converting images from one format to another. Available formats are: .gif .jpg .png .tif .bmp Uses PIL.</p> Generating random intergers within a range of max & min. (Tcl) 2003-03-04T09:58:21-08:00Dom Lamhttp://code.activestate.com/recipes/users/1023440/http://code.activestate.com/recipes/186512-generating-random-intergers-within-a-range-of-max-/ <p style="color: grey"> Tcl recipe 186512 by <a href="/recipes/users/1023440/">Dom Lam</a> (<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/math/">math</a>). </p> <p>Here's an example on how to generate a random number between 2 numbers Based on C code, algorithm = randomNumber % ((max + 1) - min) + min Here's the tcl version using rand(): *note Change 100 to 1000 if you want a random number that goes into thousands. etc.. Also the rand() function generates a number between 0 &amp; 1. That's why one would multiply by 10 or 100 or 1000, etc..</p> Download satellite images from NASA's site (Python) 2006-08-24T07:07:56-07:00Sergei Vavilovhttp://code.activestate.com/recipes/users/2974619/http://code.activestate.com/recipes/496966-download-satellite-images-from-nasas-site/ <p style="color: grey"> Python recipe 496966 by <a href="/recipes/users/2974619/">Sergei Vavilov</a> (<a href="/recipes/tags/graphics/">graphics</a>). Revision 2. </p> <p>This script downloads satellite image of desired position (in degrees) from the NASA's OnEarth site (<a href="http://onearth.jpl.nasa.gov/%29." rel="nofollow">http://onearth.jpl.nasa.gov/).</a></p> pack multiple images of different sizes into one image (Python) 2005-10-16T22:33:06-07:00S Whttp://code.activestate.com/recipes/users/1759688/http://code.activestate.com/recipes/442299-pack-multiple-images-of-different-sizes-into-one-i/ <p style="color: grey"> Python recipe 442299 by <a href="/recipes/users/1759688/">S W</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>Packing images of different sizes into one image is often required in order to efficiently use hardware accelerated texture mapping functions of 3D video cards.</p> Simple drawing tool with Python turtle graphics (Python) 2016-01-27T22:22:01-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580544-simple-drawing-tool-with-python-turtle-graphics/ <p style="color: grey"> Python recipe 580544 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/drawing/">drawing</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python2/">python2</a>, <a href="/recipes/tags/tkinter/">tkinter</a>, <a href="/recipes/tags/turtle/">turtle</a>). </p> <p>A simple drawing program that lets you use your keyboard to draw figures on screen, using the turtle graphics module built into Python.</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> 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> Change the wallpaper under Windows (Python) 2005-07-01T02:37:03-07:00Sébastien Sauvagehttp://code.activestate.com/recipes/users/2503505/http://code.activestate.com/recipes/435877-change-the-wallpaper-under-windows/ <p style="color: grey"> Python recipe 435877 by <a href="/recipes/users/2503505/">Sébastien Sauvage</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>Change the current wallpaper under Windows</p>