Skip to content

Commit

Permalink
clean-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
compartia committed Jun 25, 2023
1 parent e3028d5 commit 9f5ccd8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
10 changes: 10 additions & 0 deletions poem_letter_cache_2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@






![img1](poem_3887.png)



38 changes: 11 additions & 27 deletions poem_letter_cache_2/poem.pyde
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if DEV_MODE:
poem_t = poem_prod[0:100]

poem = None
print('begin', poem_t)

#-------------------------
class Letter:
def __init__(self, c):
Expand All @@ -105,13 +105,9 @@ class Glyph:


def draw(self):
# print('g draw 1', self.pos)
lastpos = self.pos.copy()
# print('g draw 1.1', lastpos)
lastdeg = self.deg
# print('g draw 1.2')
self.animate()
# print('g draw 2')

fill(230, 255//subframes)
if DEBUG:
Expand All @@ -121,7 +117,7 @@ class Glyph:
fill(255, 255//subframes)

blendMode(ADD)
if DEBUG:
if DEBUG: #render repulsion vector for debugging
pushMatrix()
translate(self.pos.x , self.pos.y )
stroke(255,0,0)
Expand Down Expand Up @@ -228,8 +224,6 @@ class Glyph:

#------------------------------------------------------------------------------------------------
def makeLetters(poem):

print('makeLetters 1', len(poem), textWidth )

letters = [None] * len(poem)
glyphs = [] #[None] * len(poem)
Expand All @@ -242,15 +236,15 @@ def makeLetters(poem):

last_glyph = None

print('makeLetters 2', len(poem), textWidth )
for i in range(len(poem)):

_char = poem[i]
w = textWidth(_char)

letters[i] = Letter(_char)
letters[i].pos = PVector(x, y)
# print('makeLetters 3', len(poem), textWidth )

if not (_char == ' ' or _char== '\n'):
_g = Glyph(_char)
Expand All @@ -270,31 +264,24 @@ def makeLetters(poem):
if _char == '\n':
y = y + (lineHeight * text_size)
x = 0.0


print('makeLetters 4', len(glyphs), len(letters) )


# Randomizing initial positions
for g in glyphs:
# print('makeLetters 3.1', g)
for g in glyphs:
g.pos = PVector(maxX * randomGaussian(), maxY * abs(randomGaussian()))
# g.deg = randomGaussian()*300.0

print('makeLetters bbox:', maxX, maxY)

return letters, glyphs, PVector(maxX, maxY)



def setup():
print('setup -0')

global poem, poem_t, bbox, text_size, f, number_of_lines, letters, glyphs

# with open("poem_1.txt", 'r+') as file: #DOES not work with non-ascii (
# with open("poem_1.txt", 'r+') as file: #TODO: DOES not work with non-ascii (
# lines = file.readlines()
# lines = loadStrings("poem_1.txt") #DOES not work with non-ascii (
# lines = loadStrings("poem_1.txt") #TODO: DOES not work with non-ascii (

print('setup -11')
poem = poem_t.replace("--", "—").replace(" ", " ")
print(poem_t)
size(1080/screeen_size_divider, 1920/screeen_size_divider, JAVA2D) # Instagram best reel 1920
Expand All @@ -306,14 +293,12 @@ def setup():
smooth(4)

text_size = height // 45
print('setup 1')

f = createFont("../_common/Literata-VariableFont_wght.ttf", text_size, True)
# print(f)

textFont(f, text_size)
textSize(text_size)

print(makeLetters)

letters, glyphs, bbox = makeLetters(poem)

Expand Down Expand Up @@ -373,8 +358,7 @@ def draw():
pushMatrix()
translate((width - bbox.x) / 2, 0) # center text on screen
scale(0.8) #TODO: calculate it on text size

# translate((width - bbox.x) / 2, (height - bbox.y) / 2) # center text on screen


background(0)

Expand Down

0 comments on commit 9f5ccd8

Please sign in to comment.