Alexandre B A Villares 2018-01-26 00:11:24 -02:00
rodzic 3fa388ddc9
commit f7704738cd
4 zmienionych plików z 36 dodań i 1 usunięć

Wyświetl plik

@ -4,9 +4,14 @@
Hi! I'm [Alexandre Villares](https://abav.lugaralgum.com), let's see if I can make one small program (*sketch*) a day.
![26](sketch_180126c/sketch_180126c.png)
026c: [sketch_180126b](https://github.com/villares/sketch-a-day/tree/master/sketch_180126c) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
Mouse speed changing color & strokeWeight()
![25](sketch_180125c/sketch_180125c.png)
025c: [sketch_180124b](https://github.com/villares/sketch-a-day/tree/master/sketch_180124c) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
025c: [sketch_180125b](https://github.com/villares/sketch-a-day/tree/master/sketch_180125c) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
Mouse speed changing strokeWeight()
![24](sketch_180124b/sketch_180124b.png)

Wyświetl plik

@ -0,0 +1,2 @@
mode=Python
mode.id=jycessing.mode.PythonMode

Plik binarny nie jest wyświetlany.

Po

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

Wyświetl plik

@ -0,0 +1,28 @@
"""
s18026c - Alexandre B A Villares
https://abav.lugaralgum.com/sketch-a-day
Drag the mouse over the canvas to draw
the 'brush' varies with mouse speed.
"""
pspeed = 0
def setup():
size(500, 500)
colorMode(HSB)
background(0)
def draw():
global pspeed
x, y, px, py = mouseX, mouseY, pmouseX, pmouseY
speed = (dist(x, y, px, py))**0.5 # squareroot of dist to previous mouse pos
w = ((10 - speed) + (10 - pspeed))/2 # mean of 10 minus speed & previous
stroke(map(w, 0, 10, 0, 255), 255, 255) # maps 1 to 10 to 0 to 255 scale
strokeWeight(abs(w))
if mousePressed:
line(x, y, px, py)
pspeed = speed # updates previous speed
def keyPressed():
background(0)