Archive for the ‘current status’ Category


Yay, it works! Drawing broad lines the pygamedraw way

June 23, 2010

The the basic shape algorithms are mostly implemented and I get more and more to the parts of implementing new features and improving stuff. Today I worked one the Pen.line() method or more specifically the drawing of broad poly-lines through more than two points.

First, lets have a look how the current implementation does it:

drawing a long line with pygame.draw.lines and width = 20Well, that’s just a multiple call of pygame.draw.line() which is also badly implemented as it simply adds half of the width on both sides to either the x or y values of the endpoints (and thus different angles result in different line widths). This is just ugly and nearly unusable.

So I had to fix that and do a bit more than calling Pen.line(surf, point1, point2). But what? There are quite a few ways how to draw the corners and so I added the next attribute to the Pen class, called line_style.

Currently there are 4 different line styles (and no more planned because I cannot think of any further (useful) style(s), but if you do, please tell me and I may think about it): DENTED_VERT, SHARP_VERT, FLAT_VERT and ROUND_VERT.

First of all, I did some studies and tests and thought about lines and how to draw and connect them to nice-looking polylines:

I started with a simple row of single line elements.

Then reduced it to pure data.

Some more tests and a first, ugly hacked version ensued. Then I rewrote it and did a cleaner implementation using an own Vert class to hold the data and do some calculations.

At the end, it looks like this:

Pen.line_style = DENTED_VERT

Pen.line_style = SHARP_VERT (yes, I know there is still a small pixel bug)

Pen.line_style = FLAT_VERT

Pen.line_style = ROUND_VERT

I also added a first style for line endings (more styles will come later):

Pen.line_style = ROUND_VERT Pen.line_start = ROUND_ENDING Pen.line_ending = ROUND_ENDING

Yay, that’s a lot better and more flexible than the current pygame/sdl implementation and thas is what this whole GSoC project is all about! 🙂


From Mask to Surface

June 2, 2010

The first simple shape methods have been implemented as well as some easy Pens. So far, writing an own/new Pen class is as easy as planned. Here are some images of a circle rendered with different Pens (this is directly taken from the allinone example included with the source, so feel free to view it “live”):

SolidPen - one solid color for all pixels

BlendPen - one rbga color blended in the background image

MyColorPen - an easy example for a custom Pen

TexturePen - shape filled with an image based texture

texture image used for the first example

TexturePen - just another texture (note: the texture can be exactly positioned with the texture offset)

texture image used for the second example


Step 1: Get the basics working

May 31, 2010

Currently I’m working on the very basic features that are also supported by the original pygame.draw module. When looking over these old functions (and its results), I discover more and more blemishes.

One example is pygame.draw.rect, the simplest drawing function of the whole module, you may say, but its a bit tricky, because you have to decide how a passed rect defines the pixels to draw. To be exact, I’m talking about drawing rects of a certain width. Draw around the actual rect or inside or outside? I wanted to see how the current draw module does it:

rect outline behavior

how pygame.drw.rect draws rects with certain widths

As you can see, it draws around the actual rect, ie. +width/2 and -width/2. So far, so good. But now have a look at the corner. A few pixels are missing there! It seems, it’s not a rect but just 4 lines between the vertices of the rect.

I’m going to implement this (position of the line, not the missing pixels) as default behavior, but may add alternatives like completely inside or completely outside:

rect outline position


This would also apply to other shape outlines like ellipses but I’m not sure if this would be really useful, though.


Getting Started

April 28, 2010

I’ve got a project blog and a project at with mercurial repository, issue tracker and wiki.

I also got svn access to the pygame repository, but I’d like to have an own, separate repo as well to play around without being able to break something but my own code. Nonetheless I’ll commit to the pygame repo from time to time if it’s worthwhile. Another nice side-effect of the project at bitbucket is to have an issue tracker and a wiki this way.

Then, I tried to install pygame reloaded and after installing some dependencies and getting a few “gcc failed with exit code 1” I disabled SDL_MIXER and SDL_IMAGE and it worked.

Going to read docs, play with pygame2 and think about concepts now…

… and to learn for last written exam next week.


Hello world!

April 27, 2010

Welcome to GSoC!

I’m the happy one who got the only pygame project this year and this is my project blog.