Alexandre B A Villares 2019-09-07 22:20:05 -03:00
rodzic b6ecf45f76
commit 164eed165b
16 zmienionych plików z 41 dodań i 6 usunięć

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 108 KiB

Wyświetl plik

@ -1,23 +1,21 @@
""" Draw code with comments in white """
import tokenize
cols = 2
font_size = 18
def setup():
global lines, comments
size(600, 600)
global lines, comments, fr, fb
size(800, 800)
with open("./sketch_190906a.pyde") as f:
lines = f.readlines()
comments = [] # list of comments
with open("./sketch_190906a.pyde") as f:
for tokens in tokenize.generate_tokens(f.readline):
toktype, tok, start, end_, ln = tokens
if toktype == tokenize.COMMENT or toktype == tokenize.STRING:
if toktype == tokenize.COMMENT:
comments.append(tok)
f = createFont("Inconsolata", font_size)
fr = createFont("Inconsolata", font_size)
fb = createFont("Inconsolata-Bold", font_size)
textFont(f)
noLoop() # draw() runs once and stops
def draw():
@ -26,14 +24,19 @@ def draw():
for comm in comments:
c_pos = ln.find(comm)
fill(0)
textFont(fr)
if c_pos >= 0:
code = ln[:c_pos]
c_x = textWidth(code)
text(code, 10, line_y * font_size)
fill(255)
textFont(fb)
text(comm, 10 + c_x , line_y * font_size)
break
else: # no comments (no break on comm in comments loop)
if ln.strip().startswith('"""'): # get the docstrings
fill(255)
textFont(fb)
text(ln, 10, line_y * font_size)
line_y += 1

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 12 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 16 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 12 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 16 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 15 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 16 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 11 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 14 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 14 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 11 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 15 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 13 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 16 KiB

Wyświetl plik

@ -0,0 +1,32 @@
# estudo para risografia no Sesc 24 de maio
from random import choice
def setup():
global pts
size(500, 500)
num, margin = 5, 25
w = (width - margin * 2) / num
pts = []
for i in range(num):
x = margin + w / 2 + i * w
for j in range(num):
y = margin + w / 2 + j * w
pts.append((x, y))
strokeWeight(5)
noLoop()
def draw():
background(255)
for i in range(10):
(x0, y0), (x1, y1) = choice(pts), choice(pts)
noStroke()
fill(200, 0, 0) # red
circle(x0, y0, 50)
stroke(0, 0, 200) # bluse
line(x0, y0, x1, y1)
circle(x0, y0, 5)
circle(x1, y1, 5)
def keyPressed():
saveFrame("###.png")
redraw()