Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color arrays #471

Open
almarklein opened this issue Apr 2, 2024 · 1 comment
Open

Color arrays #471

almarklein opened this issue Apr 2, 2024 · 1 comment

Comments

@almarklein
Copy link
Collaborator

almarklein commented Apr 2, 2024

The gfx.Color object stores colors internally as 4 floats in a small ctypes array (ctypes.c_float * 4). One reason for doing it this way is that it could be a view on a larger array. I don't think it can be made to work just yet, but with a few changes it should be possible to have something like:

colors_array = np.zeros((100, 4), np.float32)
color = gfx.Color.from_array_and_index(colors_array, 10)

This might be convenient because this is more efficient (and convenient?) way to store colors instead of storing an array of Color objects.

To be clear: probably needs some work in pygfx to make this work. I think its probably a good idea to think about what the ideal API be like from the pov of Fastplotlib and then probably implement that in pygfx.

@kushalkolar
Copy link
Member

kushalkolar commented May 20, 2024

I think this would be very useful for parse_colors() int graphics/_features/utils.py!

Currently in the graphic features PR:

https://github.com/fastplotlib/fastplotlib/pull/473/files#diff-ab7aaaaba02f140755a43d64627e6f9b8be46cf1f9559282e42727058ab46ee5R9-R89

This is now the only place where colors are parsed for setting line or scatter point colors.

(ignore the key argument, still have to clean it up a bit)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants