-
Notifications
You must be signed in to change notification settings - Fork 5
/
sprite_factory.py
38 lines (31 loc) · 1.3 KB
/
sprite_factory.py
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
#Copyright (c) 2009, 2011 Walter Bender
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# You should have received a copy of the GNU General Public License
# along with this library; if not, write to the Free Software
# Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GdkPixbuf
import os.path
import sprites
#
# class for defining individual cards
#
class Sprite:
def __init__(self, sw, name, x, y, w, h):
# create sprite from svg file
self.spr = sprites.Sprite(sw.sprites, x, y,
self.load_image(sw.path,name,w*sw.scale,h*sw.scale))
def draw_sprite(self, layer=1000):
self.spr.set_layer(layer)
self.spr.draw()
def load_image(self, file, name, w, h):
return GdkPixbuf.Pixbuf.new_from_file_at_size(os.path.join(file +
name +
'.svg'),
w, h)