From 2cf8315c58e067a991eecae31ceff0eb19d9d5d8 Mon Sep 17 00:00:00 2001 From: oloturia Date: Fri, 13 Sep 2019 02:01:21 +0200 Subject: [PATCH] Separated 1 character text from 2 character text The first two elements, or four elements, after the index are the coords of where the text is written Added multiple lines --- r2text.csv | 19 +++++++++++++++++++ randstrip.py | 27 +++++++++++++++++++++------ rtext.csv | 45 +++++++++++++-------------------------------- 3 files changed, 53 insertions(+), 38 deletions(-) create mode 100644 r2text.csv diff --git a/r2text.csv b/r2text.csv new file mode 100644 index 0000000..36846c9 --- /dev/null +++ b/r2text.csv @@ -0,0 +1,19 @@ +B00.0.png; +B00.1.png; +B00.2.png; +B01.png; +B02.png; +B03.png; +B04.png; +B05.png; +B06.png; +B07.png; +B08.png; +B09.png; +B10.png; +B11.png; +B12.png; +B13.png; +B14.png; +B15.png; +B16.png; diff --git a/randstrip.py b/randstrip.py index 5e27af3..f0a4954 100755 --- a/randstrip.py +++ b/randstrip.py @@ -7,11 +7,22 @@ import random def fetchText(indText): with open("rtext.csv") as rtext: - csvReader = csv.reader(rtext) + csvReader = csv.reader(rtext,delimiter=';') for row in csvReader: - if (row[0]==indText): - return row[random.randint(1,len(row)-1)] + if row[0]==indText: + return row[1],row[2],row[random.randint(3,len(row)-1)].replace('@','\n') +def fetch2Text(indText): + with open("r2text.csv") as rtext: + csvReader = csv.reader(rtext,delimiter=';') + for row in csvReader: + if row[0]==indText: + rand1 = random.randint(5,len(row)-1) + if rand1 %2 == 0: + rand1 +=1 + rand2 = rand1+1 + return row[1],row[2],row[3],row[4],row[rand1].replace('@','\n'),row[rand2].replace('@','\n') + def fetchVign(): starts = [] startdest = [] @@ -38,9 +49,13 @@ def writeStrip(story): vign = Image.open(indVign) addtext = ImageDraw.Draw(vign) fnt = ImageFont.truetype("ubuntu.ttf",16) - textVign = fetchText(indVign) - print(textVign) - addtext.text((268,77),textVign,fill="#000000",font=fnt) + if indVign[0] == 'A': + textVign = fetchText(indVign) + addtext.multiline_text((int(textVign[0]),int(textVign[1])),textVign[2],fill="#000000",font=fnt,align="center") + else: + textVign = fetch2Text(indVign) + addtext.multiline_text((int(textVign[0]),int(textVign[1])),textVign[4],fill="#000000",font=fnt,align="center") + addtext.multiline_text((int(textVign[2]),int(textVign[3])),textVign[5],fill="#000000",font=fnt,align="center") vign.show() if __name__ == "__main__": diff --git a/rtext.csv b/rtext.csv index f381ba7..4f64f64 100644 --- a/rtext.csv +++ b/rtext.csv @@ -1,32 +1,13 @@ -A00.png,Che giornata \ndel cacchio\n oggi,C'è nessuno?,Come vorrei\nundolciume,Il telefono non prende,Hey!,Bobby; dove sei?,Ciccioli di mare -A01.png, -A02.png, -A03.png, -A04.png, -A05.png, -A06.png, -A07.png, -A08.png, -A09.png, -A10.png, -A11.png, -A12.png, -B00.0.png, -B00.1.png, -B00.2.png, -B01.png, -B02.png, -B03.png, -B04.png, -B05.png, -B06.png, -B07.png, -B08.png, -B09.png, -B10.png, -B11.png, -B12.png, -B13.png, -B14.png, -B15.png, -B16.png, +A00.png;268;77;Che giornata@del cacchio@oggi;C'è nessuno?;Come vorrei@undolciume;Il telefono non prende;Hey!;Bobby, dove sei?;Ciccioli di mare +A01.png; +A02.png; +A03.png; +A04.png; +A05.png; +A06.png; +A07.png; +A08.png; +A09.png; +A10.png; +A11.png; +A12.png;