kopia lustrzana https://github.com/villares/sketch-a-day
main
rodzic
67fee1c1ae
commit
23b9eb96a3
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 101 KiB |
|
@ -0,0 +1,41 @@
|
|||
add_library('mesh')
|
||||
|
||||
# HORRIBLY SLOW
|
||||
|
||||
from villares.line_geometry import draw_poly, hatch_poly
|
||||
from villares.helpers import memoize
|
||||
|
||||
points = []
|
||||
|
||||
def setup():
|
||||
size(400, 400)
|
||||
for _ in range(30):
|
||||
points.append((random(width), random(height)))
|
||||
|
||||
def draw():
|
||||
background(200)
|
||||
points[0] = (mouseX, mouseY) # first point
|
||||
myVoronoi = Voronoi(points)
|
||||
myRegions = myVoronoi.getRegions()
|
||||
for i, region in enumerate(myRegions):
|
||||
# an array of points
|
||||
regionCoordinates = region.getCoords()
|
||||
fill(32 + i * 8, 0, 64)
|
||||
stroke(0)
|
||||
region.draw(this) # draw this shape
|
||||
# draw_poly(region.getCoords())
|
||||
coords = (tuple(c) for c in region.getCoords())
|
||||
ps = hp(tuple(coords), i, spacing=10, ps=True)
|
||||
shape(ps)
|
||||
|
||||
@memoize
|
||||
def hp(*args, **kwargs):
|
||||
return hatch_poly(*args, **kwargs)
|
||||
|
||||
# myDelaunay = Delaunay(points)
|
||||
|
||||
# edges = myDelaunay.getEdges()
|
||||
# for i, edge in enumerate(edges):
|
||||
# stroke(255, 255, 8 + i * 8)
|
||||
# startX, startY, endX, endY = edge
|
||||
# line(startX, startY, endX, endY)
|
|
@ -26,6 +26,12 @@ Here are listed some of the tools I have been using:
|
|||
|
||||
---
|
||||
|
||||

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

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