Exemplo n.º 1
0
static PyObject*
_gfx_rotozoomsizexy (PyObject *self, PyObject *args)
{
    PyObject *obj = NULL;
    int w, h, dstw, dsth;
    double angle, zoomx, zoomy;

    if (!PyArg_ParseTuple (args, "iiddd:rotozoom_size_xy", &w, &h, &angle,
            &zoomx, &zoomy))
    {
        PyErr_Clear ();
        if (PyArg_ParseTuple (args, "Oddd:rotozoom_size", &obj, &angle,
                &zoomx, &zoomy))
        {
            if (PySDLSurface_Check (obj))
            {
                w = ((PySDLSurface *)obj)->surface->w;
                h = ((PySDLSurface *)obj)->surface->w;
            }
            else
            {
                if (!SizeFromObj (obj, (pgint32*)&w, (pgint32*)&h))
                    return NULL;
            }
        }
        else
            return NULL;
    }
    rotozoomSurfaceSizeXY (w, h, angle, zoomx, zoomy, &dstw, &dsth);
    return Py_BuildValue ("(ii)", dstw, dsth);
}
Exemplo n.º 2
0
/*! 
 * @brief 将精灵绘制到屏幕上
 *
 * @param sprite 精灵的指针
 */
void Sprite_Apply (const Sprite * sprite) {
    SDL_Surface * tempSurface = NULL;
    if (sprite == NULL)
        return;
    if (!sprite->visible)
        return;
    if (sprite->surface == NULL)
        return;
    if (sprite->angle == 0.0 && sprite->zoomX == 1.0 && sprite->zoomY == 1.0) {
        Graph_ApplySurfaceTo(sprite->x,sprite->y,sprite->surface,screen);
    }
    else {
        int ow = sprite->surface->w,oh = sprite->surface->h,w,h;
        rotozoomSurfaceSizeXY(ow,oh,sprite->angle,sprite->zoomX,sprite->zoomY,&w,&h);
        tempSurface = rotozoomSurfaceXY(sprite->surface,sprite->angle,
                                        sprite->zoomX,sprite->zoomY,TRUE);
        Graph_ApplySurfaceTo(sprite->x - (w - ow) / 2,sprite->y - (h - oh) / 2,tempSurface,screen);
        SDL_FreeSurface(tempSurface);
    }
}