-
Notifications
You must be signed in to change notification settings - Fork 2
/
Card.py
47 lines (37 loc) · 1.63 KB
/
Card.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
38
39
40
41
42
43
44
45
46
47
# RaddedMC's SmartFrame v2 -- Card.py
# fileLocation -- The location of the image attached to this object. Used in Image()
# JUST GIVE THE IMAGE's FILENAME. Card.Image() will do all the heavy lifting.
# alttext -- Alternate text for the image that contains basic data.
# sourcename -- The name of the source that generated the Card.
# Image() -- returns a PIL image generated from fileLocation.
# tilesX -- returns width of image in tile units. (200 pixels per unit)
# tilesY -- returns height of image in tile units.
# Required deps: Pillow
# KEY FILES: Cards/
# Recommended card sizes:
# -- 1x1, single icon
# -- 2x2, icon and some text
# -- 4x2, long text
# -- 4x4, a lotta data
class Card:
fileLocation = ""
alttext = ""
sourcename = ""
tilesx = 2
tilesy = 2
def __init__(self, fileLocation, alttext, sourcename, tilesx, tilesy):
self.fileLocation = fileLocation
self.alttext = alttext
self.sourcename = sourcename
self.tilesx = tilesx
self.tilesy = tilesy
print("New Card | " + sourcename + "'s card at " + fileLocation + " | Size: " + str(tilesx) + "x"+str(tilesy) + " | " + alttext)
def __str__(self):
return "Card object: " + self.sourcename + "'s card at " + self.fileLocation + " | Size: " + str(self.tilesx) + "x"+str(self.tilesy) + " | " + self.alttext
def Image(self, sizex=200, sizey=200):
from PIL import Image
import os
imgdir = self.fileLocation
image = Image.open(imgdir)
image = image.resize((round(sizex), round(sizey)))
return image