August 5, 2011
July 28, 2011
$ easy_install mark3 $ python -m mark3 < myfile.textOr used as a python module:
from mark3.markdown import markdown html_output = markdown(raw_text)I wanted a markdown to html converter for python3 that was lightweight and fast. So I created mark3.
Much to my surprise I was able to get mark3 quite a lot faster than existing libraries (~7x faster).
$ hg clone https://bitbucket.org/jlm/mark3 $ cd mark3 $ python tests/speed_test.pySee the README for details on how mark3 differs from the official markdown implementation.
July 9, 2011
WebGL is awesome and all, but it's far less portable. For example, my AMD card has been blacklisted on linux. So I figured I'd revisit trying to make a real-time game with 2D canvas.
Check out the game so far.
Off-Screen RenderingOff-screen rendering is both cheep and easy to use. Here I'm using it to render map tiles to a single image. Since the tiles are (mostly) static I don't need to be redrawing them individually each frame.
setInterval is not guaranteed to call at an exact intervalSo I already knew this, but I forget how much accurate timing matters for real-time games. To the point, calculate time-past yourself with the getTime function:
var dt = new Date().getTime() - last_time;Still use setInterval for scheduling logic and render functions, just don't expect the timeout values to be consistent with actual times.
The way to avoid this problem is to limit the number objects you create and then discard. Or an easy solution; just use Chrome. It's significantly better about it.
It's better on Google ChromeSimply put, Google Chrome is better for canvas based games. Dramatically better in some situations (or rather, Firefox is dramatically worse in some situations).
July 7, 2011
Rendering to an off-screen buffer can be a great way to cache expensive drawing operations or preform post processing effects. html5's canvas element lets us do it easily.
var buffer = document.createElement('canvas'); var buffer_ctx = buffer.getContext('2d'); // ... draw to buffer_ctx ...Then simply use our new buffer as an image:
main_ctx.drawImage(buffer, 0, 0);For example, I can use an off-screen buffer to apply an expensive bloom effect:
June 2, 2011
OpenGL is one of those things I like to play with from time to time. So naturally I wanted to check out WebGL now that Chrome and Firefox support it.
Unfortunately it's noticeably slower than an equivalent program running natively. When profiling, the GL calls seemed to be the bottleneck. A bit less so on Windows than Linux, although that may have been due to better driver support on the former.
So like usual, optimizing comes down to reducing the number of GL calls you make per frame.
You can try out what I made at http://arcticpaint.com/planes/, play with the source or what ever. It's all under public domain (with the exception of the glmatrix library which has a BSD license).
I had also started toying with the idea of a turn-based game http://arcticpaint.com/islands/ (very, very far from completion)
If you want to check out more webgl stuff http://learningwebgl.com is a great resource. They also have some decent tutorials that are easy to follow along if you're new to OpenGL.