kopia lustrzana https://github.com/villares/sketch-a-day
main
rodzic
eef38c526c
commit
92d71acaac
Plik binarny nie jest wyświetlany.
|
Po Szerokość: | Wysokość: | Rozmiar: 1.4 MiB |
|
|
@ -0,0 +1,37 @@
|
|||
from villares.line_geometry import hatch_poly, draw_poly, poly_edges, Line
|
||||
def setup():
|
||||
size(400, 400)
|
||||
strokeWeight(2)
|
||||
|
||||
def draw():
|
||||
background(100, 100, 130)
|
||||
stroke(0)
|
||||
fill(255)
|
||||
r = [(75, 150), (325, 150), (325, 300), (75, 300)]
|
||||
r[0] = (mouseX, mouseY)
|
||||
# dash_line (100, 100, mouseX, mouseY)
|
||||
draw_poly(r)
|
||||
angs = [int(degrees(atan2(e[0][1] - e[1][1], e[0][0] - e[1][0]) + PI + HALF_PI))
|
||||
for e in poly_edges(r)[::2]]
|
||||
angs = {ang if ang < 180 else
|
||||
ang - 180 if ang < 360 else
|
||||
ang - 360
|
||||
for ang in angs}
|
||||
# text(str(angs), 30, 30)
|
||||
for ang in angs:
|
||||
hatch_poly(r, radians(ang), spacing=5, function=dash_line)
|
||||
|
||||
# I have modifierd Line .plot method to accept a custom drawing function
|
||||
# and also also the hatch_poly, both at github.com/villares/villares
|
||||
|
||||
def dash_line(xa, ya, xb, yb, divisions=12.5):
|
||||
for i in range(0, int(divisions * 2), 2):
|
||||
ts = i / float(divisions * 2)
|
||||
te = (i + 1) / float(divisions * 2)
|
||||
xs, ys, _ = Line(xa, ya, xb, yb).line_point(ts)
|
||||
xe, ye, _ = Line(xa, ya, xb, yb).line_point(te)
|
||||
line(xs, ys, xe, ye)
|
||||
# circle(xe, ye, 5)
|
||||
# circle(xs, ys, 5)
|
||||
|
||||
|
||||
|
|
@ -26,6 +26,12 @@ Here are listed some of the tools I have been using:
|
|||
|
||||
---
|
||||
|
||||

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

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