worm.py sample rewritten;

Minor fix in sf.SoundStream;
Updated sf.Image.


git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1019 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
remi-k 2009-02-22 14:57:18 +00:00
parent e580c8cd63
commit 49c7769273
4 changed files with 258 additions and 216 deletions

View file

@ -293,7 +293,8 @@ Copy pixels from another image onto this one. This function does a slow pixel co
Source : Source image to copy\n\
DestX : X coordinate of the destination position\n\
DestY : Y coordinate of the destination position\n\
SourceRect : Sub-rectangle of the source image to copy (empty by default - entire image)"},
SourceRect : Sub-rectangle of the source image to copy (empty by default - entire image)\n\
ApplyAlpha : Should the copy take in account the source transparency? (false by default)"},
{"Create", (PyCFunction)PySfImage_Create, METH_VARARGS, "Create(Width=0, Height=0, Color=sf.Color.Black)\n\
Create an empty image.\n\
Width : Image width\n\
@ -396,17 +397,22 @@ PySfImage_Copy(PySfImage* self, PyObject *args)
{
PySfIntRect *SourceRect = NULL;
PySfImage *Source = NULL;
unsigned int DestX, DestY;
if (! PyArg_ParseTuple(args, "O!II|O!", &PySfImageType, &Source, &DestX, &DestY, &PySfIntRectType, &SourceRect))
unsigned int DestX, DestY;
PyObject *PyApplyAlpha;
bool ApplyAlpha = false;
if (! PyArg_ParseTuple(args, "O!II|O!O", &PySfImageType, &Source, &DestX, &DestY, &PySfIntRectType, &SourceRect, &PyApplyAlpha))
return NULL;
if (PyObject_IsTrue(PyApplyAlpha))
ApplyAlpha = true;
if (SourceRect)
{
PySfIntRectUpdateObj(SourceRect);
self->obj->Copy(*(Source->obj), DestX, DestY, *(SourceRect->obj));
self->obj->Copy(*(Source->obj), DestX, DestY, *(SourceRect->obj), ApplyAlpha);
}
else
self->obj->Copy(*(Source->obj), DestX, DestY);
self->obj->Copy(*(Source->obj), DestX, DestY, sf::IntRect(0, 0, 0, 0), ApplyAlpha);
Py_RETURN_NONE;
}

View file

@ -38,6 +38,7 @@ bool CustomSoundStream::OnGetData(Chunk& Data)
if (PyObject_HasAttrString(SoundStream, "OnGetData"))
{
PyObject *PyData=NULL;
Data.NbSamples = 0;
if ((PyData = PyObject_CallFunction(PyObject_GetAttrString(SoundStream, "OnGetData"), NULL)))
{
if (PyArg_Parse(PyData, "s#", &(Data.Samples), &(Data.NbSamples)))

View file

@ -25,12 +25,12 @@
#ifndef __PYSOUNDSTREAM_HPP
#define __PYSOUNDSTREAM_HPP
#include <SFML/Audio/SoundStream.hpp>
#include <iostream>
#include <Python.h>
#include <structmember.h>
#include <SFML/Audio/SoundStream.hpp>
#include <iostream>
class CustomSoundStream : public sf::SoundStream
{
public :