electronstudio / raylib-python-cffi

Python CFFI bindings for Raylib
http://electronstudio.github.io/raylib-python-cffi
Eclipse Public License 2.0
152 stars 29 forks source link

How to use array in `draw_poly`? #124

Closed xzripper closed 4 months ago

xzripper commented 5 months ago

Drawing polygon in C:

Vector2 points[] = {{200, 200}, {400, 200}, {450, 300}, {350, 400}, {250, 400}, {150, 300}};

DrawPoly(points, etc...);

Python:

draw_poly([Vector2(200, 200), Vector2(400, 200), Vector2(450, 300), Vector2(350, 400), Vector2(250, 400), Vector2(150, 300)], etc...)

Exception: TypeError: float() not supported on cdata 'struct Vector2'

How to add multiple points?

electronstudio commented 5 months ago

That's not how you draw a polygon in C. The function is:

void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); 

It doesn't take an array.

You probably want DrawLineStrip instead.

xzripper commented 4 months ago

technically it is, thanks!