You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
3.6 KiB
Python
145 lines
3.6 KiB
Python
import re # libary to search and replace strings in the postscript file
|
|
from dictionary import font_index
|
|
from random import choice
|
|
from generate_postscript import generate_postscript
|
|
|
|
|
|
# function with three arguments
|
|
def future_relics(previous_module, current_module, module):
|
|
|
|
shape = module[1]
|
|
rotation = module[2]
|
|
x = module[3]
|
|
y = module[4]
|
|
graytone = module[5]
|
|
|
|
|
|
spike = ['spike1', 'spike2', 'spike3']
|
|
bubble = ['bubble1', 'bubble2', 'bubble3']
|
|
square = ['square1', 'square2', 'square3']
|
|
fraction = ['fraction1', 'fraction2', 'fraction3']
|
|
|
|
text = ""
|
|
font = ""
|
|
fontsize = ""
|
|
linewidth = ""
|
|
|
|
|
|
if shape == "spike":
|
|
form = choice(spike)
|
|
if form == 'spike1':
|
|
text = "f/yk"
|
|
font = "Helvetica-BoldOblique"
|
|
fontsize = "60"
|
|
linewidth = "100"
|
|
elif form == 'spike2':
|
|
text = "f/yk"
|
|
font = "Helvetica-BoldOblique"
|
|
fontsize = "30"
|
|
linewidth = "100"
|
|
elif form == 'spike3':
|
|
text = "xxx"
|
|
font = "Helvetica-BoldOblique"
|
|
fontsize = "100"
|
|
linewidth = "100"
|
|
|
|
elif shape == "bubble":
|
|
form = choice(bubble)
|
|
if form == 'bubble1':
|
|
text = "gooo"
|
|
font = "Courier"
|
|
fontsize = "160"
|
|
linewidth = "80"
|
|
elif form == 'bubble2':
|
|
text = "dP"
|
|
font = "Courier"
|
|
fontsize = "160"
|
|
linewidth = "80"
|
|
elif form == 'bubble3':
|
|
text = "oOgOö"
|
|
font = "Courier"
|
|
fontsize = "250"
|
|
linewidth = "80"
|
|
|
|
elif shape == "square":
|
|
form = choice(square)
|
|
if form == 'square1':
|
|
text = "FRICTION"
|
|
font = "Helvetica-BoldOblique"
|
|
fontsize = "2"
|
|
linewidth = "300"
|
|
elif form == 'square2':
|
|
text = "LLL"
|
|
font = "Helvetica-BoldOblique"
|
|
fontsize = "100"
|
|
linewidth = "300"
|
|
elif form == 'square3':
|
|
text = "|||"
|
|
font = "Courier"
|
|
fontsize = "100"
|
|
linewidth = "200"
|
|
|
|
elif shape == "fraction":
|
|
form = choice(fraction)
|
|
if form == 'fraction1':
|
|
text = "3ß"
|
|
font = "Courier"
|
|
fontsize = "100"
|
|
linewidth = "600"
|
|
elif form == 'fraction2':
|
|
text = "%?"
|
|
font = "Courier"
|
|
fontsize = "100"
|
|
linewidth = "200"
|
|
elif form == 'fraction3':
|
|
text = "WM"
|
|
font = "Courier"
|
|
fontsize = "100"
|
|
linewidth = "200"
|
|
|
|
|
|
|
|
script = """
|
|
|
|
newpath
|
|
% FUTURE RELICS
|
|
|
|
/"""+font+"""
|
|
% fontname
|
|
|
|
"""+fontsize+""" selectfont
|
|
% fontsize in points, establishes the font as the current one
|
|
|
|
"""+x+""" """+y+""" moveto
|
|
% x and y coordinates in px (origin is the lower-left corner of the page)
|
|
|
|
"""+rotation+""" rotate
|
|
% degree of rotation, counter clockwise around the given position
|
|
|
|
("""+text+""") true charpath
|
|
% normally text works with "show", but to use the characters in the string as a path that can be stroked and filled use "true charpath"
|
|
|
|
gsave
|
|
% save the current path to apply stroke first and then go back to the saved path to apply fill (Both drawing commands destroy the current path)
|
|
|
|
"""+linewidth+""" setlinewidth
|
|
% linewidth for the outline of the text
|
|
|
|
"""+graytone+""" setgray
|
|
% graytone for the outline (0 = black, 1 = white)
|
|
|
|
stroke
|
|
% stroke (outline) the text in parentheses
|
|
|
|
-"""+rotation+""" rotate
|
|
% set rotation back to zero
|
|
|
|
showpage
|
|
% print all on a page
|
|
"""
|
|
|
|
|
|
|
|
|
|
generate_postscript(previous_module, current_module, script) # call function
|