File: graphics.pxd

package info (click to toggle)
python-sfml 1.5.1.is.1.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,456 kB
  • ctags: 1,585
  • sloc: python: 5,747; cpp: 285; makefile: 147
file content (79 lines) | stat: -rw-r--r-- 2,546 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# pySFML - Python bindings for pySFML
# Copyright 2012-2013, Jonathan De Wachter <dewachter.jonathan@gmail.com>
#
# This software is released under the LGPLv3 license.
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


cimport libcpp.sfml as sf
from pysfml.system cimport Vector2

cdef extern from "pysfml/graphics.h":
	cdef class sfml.graphics.Rectangle [object PyRectangleObject]:
		cdef public Vector2 position
		cdef public Vector2 size

	cdef class sfml.graphics.Color [object PyColorObject]:
		cdef sf.Color *p_this

	cdef class sfml.graphics.Image [object PyImageObject]:
		cdef sf.Image *p_this

	cdef class sfml.graphics.Texture [object PyTextureObject]:
		cdef sf.Texture *p_this
		cdef bint               delete_this

	cdef class sfml.graphics.Drawable [object PyDrawableObject]:
		cdef sf.Drawable *p_drawable

	cdef class sfml.graphics.TransformableDrawable(Drawable) [object PyTransformableDrawableObject]:
		cdef sf.Transformable *p_transformable

	cdef class sfml.graphics.Sprite(TransformableDrawable) [object PySpriteObject]:
		cdef sf.Sprite *p_this
		cdef Texture           m_texture

	cdef class sfml.graphics.Shape(TransformableDrawable) [object PyShapeObject]:
		cdef sf.Shape *p_shape
		cdef Texture          m_texture

	cdef class sfml.graphics.ConvexShape(Shape) [object PyConvexShapeObject]:
		cdef sf.ConvexShape *p_this

	cdef class sfml.graphics.RenderTarget [object PyRenderTargetObject]:
		cdef sf.RenderTarget *p_rendertarget

	cdef class sfml.graphics.RenderStates [object PyRenderStatesObject]:
		pass

cdef inline sf.FloatRect to_floatrect(rectangle):
	l, t, w, h = rectangle
	return sf.FloatRect(l, t, w, h)

cdef inline sf.IntRect to_intrect(rectangle):
	l, t, w, h = rectangle
	return sf.IntRect(l, t, w, h)

cdef inline Rectangle intrect_to_rectangle(sf.IntRect* intrect):
	return Rectangle((intrect.left, intrect.top), (intrect.width, intrect.height))

cdef inline Rectangle floatrect_to_rectangle(sf.FloatRect* floatrect):
	return Rectangle((floatrect.left, floatrect.top), (floatrect.width, floatrect.height))

cdef inline Color wrap_color(sf.Color *p):
	cdef Color r = Color.__new__(Color)
	r.p_this = p
	return r

cdef inline ConvexShape wrap_convexshape(sf.ConvexShape *p):
	cdef ConvexShape r = ConvexShape.__new__(ConvexShape)
	r.p_this = p
	r.p_drawable = <sf.Drawable*>p
	r.p_transformable = <sf.Transformable*>p
	r.p_shape = <sf.Shape*>p

	return r