kopia lustrzana https://github.com/villares/sketch-a-day
23+readme
rodzic
4e34a56012
commit
d857bc7ee6
Plik binarny nie jest wyświetlany.
|
Po Szerokość: | Wysokość: | Rozmiar: 380 KiB |
|
|
@ -0,0 +1,83 @@
|
|||
# import copy as cp
|
||||
|
||||
add_library('pdf')
|
||||
polys = []
|
||||
current_poly = []
|
||||
divisoes = 5
|
||||
salvar_pdf = False
|
||||
ponto_clique = []
|
||||
|
||||
def setup():
|
||||
size(700, 700)
|
||||
strokeJoin(ROUND)
|
||||
|
||||
def draw():
|
||||
if salvar_pdf:
|
||||
beginRecord(PDF, "####.pdf")
|
||||
|
||||
mh, mv = width / 2, height / 2
|
||||
translate(mh, mv)
|
||||
background(240, 240, 200)
|
||||
|
||||
angulo = radians(360. / divisoes)
|
||||
fill(0, 0, 200)
|
||||
noStroke()
|
||||
for num in range(divisoes):
|
||||
rotate(angulo)
|
||||
for poly in polys:
|
||||
# (x1, y1), (x2, y2) = poly
|
||||
print poly
|
||||
draw_poly(poly)
|
||||
scale(-1, 1)
|
||||
draw_poly(poly)
|
||||
scale(-1, 1)
|
||||
|
||||
if salvar_pdf:
|
||||
endRecord()
|
||||
global salvar_pdf
|
||||
salvar_pdf = False
|
||||
|
||||
if current_poly:
|
||||
noFill()
|
||||
stroke(0)
|
||||
for num in range(divisoes):
|
||||
rotate(angulo)
|
||||
draw_poly(current_poly + [(mouseX, mouseY)])
|
||||
scale(-1, 1)
|
||||
draw_poly(current_poly + [(mouseX, mouseY)])
|
||||
scale(-1, 1)
|
||||
|
||||
def draw_poly(poly):
|
||||
pushMatrix()
|
||||
translate(-width / 2, -height / 2)
|
||||
beginShape()
|
||||
for p in poly:
|
||||
vertex(p[0], p[1])
|
||||
endShape(CLOSE)
|
||||
popMatrix()
|
||||
|
||||
def mousePressed(): # def mouseDragged():
|
||||
if mouseButton == LEFT:
|
||||
current_poly.append((mouseX, mouseY))
|
||||
if mouseButton == RIGHT:
|
||||
polys.append(current_poly + [(mouseX, mouseY)])
|
||||
current_poly[:] = []
|
||||
|
||||
def keyPressed():
|
||||
global salvar_pdf, divisoes
|
||||
if key == "a":
|
||||
polys[:] = [[]] # esvazia lista de polys
|
||||
ponto_clique[:] = []
|
||||
if key == "g":
|
||||
saveFrame("#####.png")
|
||||
print("salvando PNG")
|
||||
if key == "p":
|
||||
salvar_pdf = True
|
||||
print("salvando PDF")
|
||||
if key == BACKSPACE and polys:
|
||||
polys.pop()
|
||||
if key == "-" and divisoes > 2:
|
||||
divisoes -= 1
|
||||
if key == "+" or key == "=":
|
||||
divisoes += 1
|
||||
|
||||
27
README.md
27
README.md
|
|
@ -18,6 +18,33 @@ You may also support my artistic work, open teaching resources and research with
|
|||
|
||||
## 2019
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
[sketch_190823c](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190823c) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
|
||||
|
||||
Interactive symmetryc polygons
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
[sketch_190822c](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190822c) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
|
||||
|
||||
Interactive symmetric lines
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
[sketch_190821c](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190821c) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
[sketch_190820a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190820a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue