[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] circular setion on an array
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
jabberwocky <azazel_arms@yahoo.it> said:
> If I have an array with all zeros, there is a way to
> change to 1 some positions in order to get a full
> circle drawned by the 1s? or better, having all 1s in
> the array change to 0 the positions out of the
> "circle", in other words I need a way to select
> elliptical section onto an array...
> [...]
You could draw a circle using pygame.draw.circle and pull the array with
surfarray. If you want something with a higher precision or speed, use
Numeric.fromfunction, with function with function ((x**2 + y**2 - r**2) < 0).
Since you'll probably want to avoid Python funcalls, you could try playing
with an array generated by Numeric.indices and the logical operators. It
*will* be faster, but you probably shouldn't do it unless there's a proven
bottleneck in your code (use the profiler!).
[]s,
- --
Fábio "ctg \pi" Dias Moreira
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQFAXvExalOQFrvzGQoRAgq8AKCGYkEsfgTKdu6b4/HF82QjW2PqLwCg0PBi
kjroESmpi2xEcOimRqpdOTY=
=FvC+
-----END PGP SIGNATURE-----