Alexandre B A Villares 2020-09-22 01:08:11 -03:00
rodzic f3d3bb156a
commit 1abe6aedfe
4 zmienionych plików z 68 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,17 @@
class Ponto():
SIZE = 5
def __init__(self, x, y):
self.x = x
self.y = y
self.f = 255
def __getitem__(self, i):
return (self.x, self.y)[i]
def draw(self):
fill(self.f)
circle(self.x, self.y, Ponto.SIZE)

Plik binarny nie jest wyświetlany.

Po

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

Wyświetl plik

@ -0,0 +1,45 @@
from ponto import Ponto
pontos = []
dragg = []
def setup():
size(400, 400)
for _ in range(20):
pontos.append(Ponto(random(width),
random(height)))
def draw():
background(200)
if len(dragg) == 2:
line(dragg[0][0], dragg[0][1], mouseX, mouseY)
for p in pontos:
if len(dragg) == 2:
if area(p, dragg[0], dragg[1]) > 0:
p.f = color(255, 0, 0)
else:
p.f = color(0, 0, 255)
else:
p.f = 255
p.draw()
def mousePressed():
dragg[:] = [(mouseX, mouseY)]
def mouseDragged():
if len(dragg) == 1:
dragg.append((mouseX, mouseY))
else:
dragg[1] = (mouseX, mouseY)
def area(p0, p1, p2):
a = (p1[0] * (p2[1] - p0[1]) +
p2[0] * (p0[1] - p1[1]) +
p0[0] * (p1[1] - p2[1]))
return a
def mouseReleased():
dragg[:] = []

Wyświetl plik

@ -26,6 +26,12 @@ Some of the tools I have used:
---
![sketch_2020_09_21a](2020/sketch_2020_09_21a/sketch_2020_09_21a.gif)
[sketch_2020_09_21a](https://github.com/villares/sketch-a-day/tree/master/2020/sketch_2020_09_21a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
---
![sketch_2020_09_20polycubes_p5py](2020/sketch_2020_09_20polycubes_p5py/sketch_2020_09_20polycubes_p5py.gif)
[sketch_2020_09_20polycubes_p5py](https://github.com/villares/sketch-a-day/tree/master/2020/sketch_2020_09_20polycubes_p5py) [[p5py](https://github.com/p5py/p5)]]