[pygame] gsoc: pygamedraw - status update

2010-06-17 Thread jug

Hello,

I'd like to give you a short status report of the pygamedraw gsoc project.
I've implemented the main class structure and basic drawing methods, so 
its already usable:


# ...
red = pygame2.Color(200, 0, 0)
blue = pygame2.Color(0, 0, 200)
my_pen = SolidPen(color=red)
my_pen.width = 6
rect1 = pygame2.Rect(20, 60, 200, 150)
my_pen.width = 1
my_pen.ellipse(screen, rect1)
rect2 = pygame2.Rect(30, 20, 50, 80)
my_pen.ellipse(screen, rect2, start=30, stop=250)
my_pen.color = blue
my_pen.fill = True
my_pen.cirlce(screen, (150, 170), 60, stop=90)
my_pen.fill = False
points = [(20, 50),  (60, 10),  (70, 80)]
my_pen.line(screen, points, closed=True)
# ...

This should be mostly self-explanatory.
In comparison to the current draw module(s) you will notice
that it is object oriented!

Draw functions on module level are replaced by draw methods
on class level. This is the main change that brings along some
advantages and changes:

1.) possibility of inheritance
This is a great new feature that allows it to manipulate the way
of drawing without touching any shape algorithms. These are
implemented in the Pen base class and work on a mask as
intermediate. This mask is then passed to the Pen.render() method
that does some preparation and then calls the Pen.draw() method
that implements the actual drawing. So you just need to subclass
Pen and overwrite one method (namely Pen.draw()) and have a
completely new drawing behavior for all shapes.
Of course there will be some default Pens that already implement
the most common drawing methods. There are some screen shots
of already implemented Pens at my blog:
http://pygamedraw.wordpress.com/2010/06/02/from-mask-to-surface/
If you have any ideas for further Pen classes please tell me.

2.) shorter parameter lists
Having a Pen object allows it to store general parameters as class
attributes, so drawing methods take only a minimum of parameters.
However, I plan to add a way to set these class attributes on method
class, so if you don't like to write my_pen.width=1/2/... all the time,
you could set it directly on method call (like with the current pygame.draw
module): my_pen.rect(surf, rect, width=2).

 3.) cleaner code
I think this makes the code cleaner, more structured and more pythonic.

A more complex example is included with the sourcecode:
http://bitbucket.org/schlangen/pygamedraw/get/2c2c8b815137.zip
or
hg clone http://bitbucket.org/schlangen/pygamedraw


Regards,
Julian



Re: [pygame] gsoc: pygamedraw - status update

2010-06-17 Thread René Dudfield
sweet as :)


Re: [pygame] gsoc: pygamedraw - status update

2010-06-17 Thread Henrique Nakashima
The module is looking very nice so far, I'm looking forward to using it =)

Have you though about implementing the Pen class as an abstract class with
the abc module? That would prevent Pen from being directly instantiated.

On Thu, Jun 17, 2010 at 13:29, René Dudfield ren...@gmail.com wrote:

 sweet as :)



Re: [pygame] gsoc: pygamedraw - status update

2010-06-17 Thread Lenard Lindstrom

Looking good.

Lenard



Re: [pygame] gsoc: pygamedraw - status update

2010-06-17 Thread Lorenz Quack

Hey,

I have to agree with the other comments. it's really looking good so far!

On 06/17/2010 06:05 PM, jug wrote:

Hello,

I'd like to give you a short status report of the pygamedraw gsoc project.
I've implemented the main class structure and basic drawing methods, so
its already usable:


[...]

If you have any ideas for further Pen classes please tell me.

[...]
 Regards,
 Julian


I just thought that it *might* be useful to have an attribute style or 
something like that
which can be set to SOLID, DOTTED or DASHED in analogy to the css 
attribute border-style [1].
I don't think this is a top priority item but might be nice to have.

keep up the good work

//Lorenz

[1] http://www.tizag.com/cssT/border.php



Re: [pygame] gsoc: pygamedraw - status update

2010-06-17 Thread Luke Paireepinart
Hey, I'm in need of some fast drawing functions that can correctly
paint brush strokes... eg. if I draw a series of points 1px apart,with
alpha, is it going to look like a bunch of overlapping circles, or is
it going to look like a thick line of the correct alpha value?

Also, these are implemented in pure Python?  How fast are they?  do
they do a lot of work in Python or is most of it done in existing SDL
code or something?

And how can I test this out?  Do I just install Pygame Reloaded and
then add this to my project folder and import it?

Thanks,
-Luke

On Thu, Jun 17, 2010 at 3:54 PM, Lorenz Quack d...@amberfisharts.com wrote:
 Hey,

 I have to agree with the other comments. it's really looking good so far!

 On 06/17/2010 06:05 PM, jug wrote:

 Hello,

 I'd like to give you a short status report of the pygamedraw gsoc project.
 I've implemented the main class structure and basic drawing methods, so
 its already usable:

 [...]

 If you have any ideas for further Pen classes please tell me.

 [...]
 Regards,
 Julian


 I just thought that it *might* be useful to have an attribute style or
 something like that
 which can be set to SOLID, DOTTED or DASHED in analogy to the css
 attribute border-style [1].
 I don't think this is a top priority item but might be nice to have.

 keep up the good work

 //Lorenz

 [1] http://www.tizag.com/cssT/border.php