Showing circles. Numpy array works fine but Field doesn't #8405
Unanswered
Deanodirector
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, the Following code give me an error "AttributeError: 'ScalarField' object has no attribute 'astype'. Did you mean: 'dtype'?"
but works fine if I use a numpy array. If i print them out they are identical. Whats the issue here? thanks
`import taichi as ti
import numpy as np
ti.init(arch=ti.vulkan)
gui = ti.GUI('Circles Test', res=(640, 480))
numpoints = 20
centres = ti.field(ti.f32, shape=(numpoints, 2))
#centres = np.random.random((50, 2))
@ti.kernel
def randompoints():
for i, j in centres:
centres[i,j] =ti.random()
randompoints()
print(centres)
#center = [0.3, 0.5]
while gui.running:
gui.circles(centres, radius= 20, color=0xEEEEF0)
gui.show()`
Beta Was this translation helpful? Give feedback.
All reactions