Projects tagged "python"
This page highlights several of my personal software projects.
Table of Contents
SDF Modeling January 2021
Generate 3D meshes based on signed distance functions with a dirt simple Python API.
The goal of this library is to provide a simple, fun, and easy-to-use API for generating 3D models in our favorite language Python. The code simply uses the Marching Cubes algorithm to generate a mesh from a signed distance function (SDF). This would normally be abysmally slow in Python. However, numpy is used to evaluate the SDF on entire batches of points simultaneously. Furthermore, multiple threads are used to process batches in parallel. The result is surprisingly fast (for marching cubes). Supports text, 2D extrusion & revolution, image masks, various file formats, and more!
The code below is a complete example which generates the model shown in the image. This is the canonical Constructive Solid Geometry example. Note the use of operators for intersection, union, and difference.
from sdf import *
f = sphere(1) & box(1.5)
c = cylinder(0.5)
f -= c.orient(X) | c.orient(Y) | c.orient(Z)
f.save('out.stl')
Links: GitHub
AxiDraw January 2017
Unofficial Python library for working with the AxiDraw pen plotter.
The AxiDraw is a very nice modern pen plotter. It ships with Inkscape-based software for controlling it, but I was more interested in programmatically controlling it myself. So I wrote this library that controls the plotter directly over the USB serial port.
The most interesting part of this project, for me, was writing my own motion planning algorithm. I stuck with constant-acceleration for simplicity, and the code for the planner came out to just a couple hundred lines of Python!
See the motion planning algorithm in action in this web-based visualization.
Features
- control the AxiDraw directly from Python with a simple API
- convenient command-line utility
- constant acceleration (trapezoidal velocity) motion planning
- path drawing order optimization
- drawing transformations
- preview drawing (render to png)
- turtle graphics
- lindenmayer systems
Links: GitHub • Medium Article
Pirate Maps December 2015
Procedurally generated pirate treasure maps. X marks the spot!
This was my submission in the /r/proceduralgeneration monthly challenge. I used several excellent third party libraries...
cairo
for renderingcolour
for color interpolationnoise
for simplex noisePillow
for saving debug images of noise layerspyhull
for delaunay triangulationShapely
for all kinds of 2D geometry operations
Links: GitHub
GPS September 2014
Real-time 3D visualization of actual GPS satellite locations.
This code interfaces with a USB GPS receiver and produces a 3D visualization of GPS satellite positions for all of the satellites that are currently in view.
Links: GitHub
HiRISE August 2014
Fly through real Martian landscapes using data released by HiRISE.
This code converts HiRISE DTMs from their PDS format to a 3D mesh in STL format with an accompanying normal map texture for high-resolution lighting. The visualizer was written using pg
, my Python OpenGL library.
Links: GitHub
Tiling June 2014
Quickly construct tilings of regular polygons and their dual tilings using a simple API.
This code provides an interesting API for constructing tilings of regular polygons. It can also render the dual tilings.
Links: GitHub
Quads May 2014
Computer art based on quadtrees.
The program targets an input image. The input image is split into four quadrants. Each quadrant is assigned an averaged color based on the colors in the input image. The quadrant with the largest error is split into its four children quadrants to refine the image. This process is repeated N times.
Links: GitHub • Web Version
AllRGB March 2014
Generate images that use all 16,777,216 RGB colors exactly once.
Efficiently create AllRGB images that target an input image. The input must be 4096x4096px. The output will also be 4096x4096px and will contain all 16,777,216 distinct RGB values once and only once.
See allrgb.com for details on the concept.
Links: GitHub
Graph Layout February 2014
Experimenting with graph visualization using simulated annealing for layout.
Graphviz is the main player when it comes to graph visualization. But its output isn't very appealing, at least not by default. With this in mind, and being a fan of simulated annealing, I experimented with using annealing for graph layout. The results are pretty good, but it probably doesn't scale very well. The algorithm basically tries to minimize the following metrics, with different weights applied to each:
- Node-Node Intersections
- Node-Edge Intersections
- Edge-Edge Intersections
- Edge Lengths
- Total Graph Area
- Node Rank Violations
Links: GitHub
Piet September 2013
Procedurally generating Images in the style of Piet Mondrian.
Piet Mondrian was a Dutch painter. His paintings with orthogonal lines and rectangular splashes of primary colors on white backgrounds are very recognizable. I wondered what it would take to programmatically generate Mondrian-esque images. Here's what I came up with.
Links: GitHub
Craft April 2013
Minecraft clone for Windows, Mac and Linux.
A very performant Minecraft clone written in just a few thousand lines of C using modern OpenGL (shaders). Online multiplayer support is included using a Python-based server. Many people have used this as a base upon which a more complex game was built.
Download
DCPU-16 April 2012
An assembler, disassembler and emulator for the virtual DCPU-16 written in Python and C.
The DCPU-16 was intended to form the basis of a video game by Mojang called 0x10c. Work on the game has since discontinued, but at the time there was a lot of excitement around this virtual hardware.
Implemented Specifications
- DCPU-16 1.7
- LEM1802
- Generic Keyboard
- Generic Clock
Links: GitHub
iMeme February 2012
Meme generator for Windows and Mac that lets you quickly add captions to popular internet memes.
Download
Features
- Over 100 built-in templates.
- Enter your own header and footer text.
- Adjustable text size and alignment.
- Use your own images.
- Save as PNG or copy to the clipboard.
- Print directly from the app.
- Automatically upload to imgur.
- Automatically post to reddit.
Ricochet Robot February 2012
Implementation of a board game called Ricochet Robot including a GUI and a very fast solver.
My friend introduced me to a board game called Ricochet Robot (or Rasende Roboter in its original German form). It's a fun game, but I found it even more fun as a programming problem. I implemented the game in Python, including a user interface and a solver. After that, I sped up the solver tremendously by porting it to C. My solver includes several "tricks" that make it quite fast. See these slides for more details.
Feed Notifier January 2010
Real-time popup notifications for RSS and Atom Feeds on Windows and macOS.
Feed Notifier is an application for Windows and macOS that resides in the system tray or menu bar and displays pop-up notifications on your desktop when new items arrive in your subscribed RSS or Atom feeds.
Feed Notifier is for you if you want a news aggregator that focuses on real-time feed notifications and leaves out all the other stuff that comes with most news readers.