We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to make something in Python mode, but I need toxiclibs. I try using Vec3D, but when I try to read the Vec3D coordinate values it tells me they aren't of the float type and that " argument can't be coerced to float".
I use Python type function to check the datatypes of the Vec3D object and its 'x' attribute and I get:
<type 'toxi.geom.Vec3D'>
<type 'instancemethod'>
And here is the code I mention:
add_library('toxiclibscore')
vector = 1
def setup():
size(200,600)
vector = Vec3D(width/2,height/2,0)
def draw():
print(type(vector.x))
ellipse(vector.x ,vector.y, 3, 3)
Answers
Um, help?
Maybe I wasn't clear enough. When I ask for the Vec3D object "x" (or "y") attribute, I get the error I mentioned. It should return a float value, but when I use Python's type() function to determine the kind of value I'm getting, I don't get "float", but "instancemethod" (?).
Not all libraries will work in Python mode I suggest you send a PM to @JonathanFeinberg the creator of Python mode.
Thanks, I think I'll do that.
Don't know if you ever got this answered, but the issue here is that the toxic libs are properly designed for the end-user; i.e. object fields can't be accessed directly:
would give you an
x
which is, indeed, a method; an accessor method for the private fieldx
.You would need to invoke it as
x = vector.x()
to get the value of the vector'sx
.