# Nice Shadertoy Sketch in py5

**URL:** <https://discourse.processing.org/t/nice-shadertoy-sketch-in-py5/33088>\
**Category:** Gallery\
**Created:** [October 26, 2021, 1:19pm UTC](https://discourse.processing.org/t/nice-shadertoy-sketch-in-py5/33088 "2021-10-26T13:19:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [October 26, 2021, 1:19pm UTC](https://discourse.processing.org/t/nice-shadertoy-sketch-in-py5/33088/1 "2021-10-26T13:19:44Z")

</div>

Previously I converted a recent shadertoy sketch to [JRubyArt](https://discourse.processing.org/t/nice-shader-toy-sketch-in-jrubyart/33060), for the benefit of py5 followers @tabreturn @villares @hx2A , here is same sketch translated to py5.

```python
import py5
from vec2d import vec2d
# taste of noise 7 by leon denise 2021/10/14
# result of experimentation with organic patterns
# using code from Inigo Quilez, David Hoskins and NuSan
# thanks to Fabrice Neyret for code reviews
# licensed under hippie love conspiracy
def settings():
    py5.full_screen(py5.P2D)

def setup():
    global wrapper, img, previous_time, last_mouse_position, mouse_click_state, start
    previous_time = 0.0
    mouse_dragged = False
    mouse_click_state = 0.0
    last_mouse_position = vec2d.Vec2D(py5.mouse_x, py5.mouse_y)
    wrapper = py5.load_shader('data/taste_of_noise7.glsl')
    img = py5.load_shader('data/image.glsl')
    # Assume the dimension of the window will not change over time
    wrapper.set('iResolution', py5.width, py5.height, 0.0)
    start = py5.millis()

def draw():
    global last_mouse_position
    wrapper.set('iTime', playback_time_seconds())
    previous_time = playback_time_seconds()
    img.set('iChannel0', py5.get())
    # mouse pixel coords. xy: current (if MLB down), zw: click
    if py5.is_mouse_pressed:
        last_mouse_position = vec2d.Vec2D(py5.mouse_x, py5.mouse_y)
        mouse_click_state = 1.0
    else:
        mouse_click_state = 0.0

    wrapper.set('iMouse', last_mouse_position.x, last_mouse_position.y, mouse_click_state, mouse_click_state)
    py5.shader(wrapper)
    # Draw the output of the shader onto a rectangle that covers the whole viewport.
    py5.rect(0, 0, py5.width, py5.height)

def playback_time_seconds():
    return (py5.millis() - start) / 1000.0

py5.run_sketch()

```

vec2d

```python
class Vec2D(object):
    def __init__ (self, x, y):
        self.x = x
        self.y = y

```

For shaders see JRubyArt example

---

<div class="post-metadata">

**Author:** ![hx2A](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hx2a/32/14322_2.png) [@hx2A](https://discourse.processing.org/u/hx2A)\
**Post date:** [October 26, 2021, 2:05pm UTC](https://discourse.processing.org/t/nice-shadertoy-sketch-in-py5/33088/2 "2021-10-26T14:05:40Z")

</div>

I like this! Thank you for sharing! And great use of the py5 library.
