-
I was studying the Numpy Vectorization tutorial, when I use import py5
import numpy as np
s = 0.005
ygrid, xgrid = np.mgrid[0:500:10, 0:500:10]
def setup():
py5.size(500, 500, py5.P3D)
py5.noise_seed(0)
py5.color_mode(py5.HSB)
def draw():
py5.background(0)
py5.lights()
py5.translate(py5.width / 2, py5.height / 2, py5.height / 2)
py5.rotate_x(py5.QUARTER_PI)
py5.translate(-py5.width / 2, -py5.height / 2, 0)
# d = 128 + 128 * py5.os_noise(frame_count * s, xgrid * s, ygrid * s) # try for compariisson...
d = 128 + 128 * py5.os_noise(xgrid * s, ygrid * s, py5.frame_count * s)
my_box(xgrid, ygrid, -200 + d / 2, 10, 10, d)
print(py5.frame_count)
@np.vectorize
def my_box(x, y, z, *args):
py5.push()
py5.translate(x, y, z)
py5.fill(args[-1] % 256, 200, 200)
py5.box(*args)
py5.pop()
py5.run_sketch() |
Beta Was this translation helpful? Give feedback.
Answered by
hx2A
Aug 21, 2022
Replies: 1 comment 1 reply
-
This is a bug, caused by a stupid typo. Good catch! BTW, I think you want |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
villares
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a bug, caused by a stupid typo. Good catch!
BTW, I think you want
os_noise_seed()
if you are usingos_noise()
. I'm glad you gave vectorization a try here, both because it is faster and because it uncovered this bug.