diff --git a/README.md b/README.md index fba1dab3..46b9c11b 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/sketch_180126c/sketch.properties b/sketch_180126c/sketch.properties new file mode 100644 index 00000000..2456b0ab --- /dev/null +++ b/sketch_180126c/sketch.properties @@ -0,0 +1,2 @@ +mode=Python +mode.id=jycessing.mode.PythonMode diff --git a/sketch_180126c/sketch_180126c.png b/sketch_180126c/sketch_180126c.png new file mode 100644 index 00000000..8b1bf232 Binary files /dev/null and b/sketch_180126c/sketch_180126c.png differ diff --git a/sketch_180126c/sketch_180126c.pyde b/sketch_180126c/sketch_180126c.pyde new file mode 100644 index 00000000..7f2c4ec4 --- /dev/null +++ b/sketch_180126c/sketch_180126c.pyde @@ -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) \ No newline at end of file