[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Surfarray Help
- To: "pygame-users@xxxxxxxx" <pygame-users@xxxxxxxx>
- Subject: [pygame] Surfarray Help
- From: Ian Mallett <geometrian@xxxxxxxxx>
- Date: Wed, 8 Apr 2009 16:07:52 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Wed, 08 Apr 2009 19:07:54 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=4CSLNfvM6DJLcYf1bjubxS/9l3RGh19EsRx8fA/pVD4=; b=rZE07bhH5PfXnSw10zYvd0JOxUbb3VN7QprO3QO5HhHd/Zi0G+SRe9LmQu5YA3jBK3 ruRDUBNA07SB/h6hCwa9mHVTfUoOYxQ5PMWh/gCJJv3Zc096YABYOBYNNH6LkC9bEzp1 SlpsOCj/YEuEJMVIUVrvhVFw+iHflyEhMk9dw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Rx87ndRAp5nJ+iakQNRMm8/0BuR8cvr2HvGHkuAacxUzg2W6mjmPzP4FVdYoWmjptl Tg0pqstcsFObavqXVDY7OGJSOEls9Z/HyKaf704Zms2FZolQGfo9TFw6ksYVsg6dj7vV Eh030sOct/2XElCAZFkmACxxQGD+GigwH7JvY=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hello,
I want to make a surface of size sqrt(n) on a side filled with special values.
The values range from 0.0 to 3.0, starting with 0.0 at one corner and ending at 3.0 in the opposite, increasing going row by row. The value is to be encoded in each color. Because this is somewhat abstract, here's a small example (n=25), generated using the attached code (it also multiplies the number by 255 to obtain a RGB color). The real version should be done by surfarray. This is where I need help; I have no idea how to even approach the problem.
[[ 0, 0, 0],[ 32, 0, 0],[ 64, 0, 0],[ 96, 0, 0],[128, 0, 0],
[159, 0, 0],[191, 0, 0],[223, 0, 0],[255, 0, 0],[255, 32, 0],
[255, 64, 0],[255, 96, 0],[255,128, 0],[255,159, 0],[255,191, 0],
[255,223, 0],[255,255, 0],[255,255, 32],[255,255, 64],[255,255, 96],
[255,255,128],[255,255,159],[255,255,191],[255,255,223],[255,255,255]]
Arrays like this need to be generated quite quickly, so the per-pixel method I presented will not work. How should I do it with surfarray?
Thanks,
Ian
Attachment:
particlesurfgen.py
Description: Binary data