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

Set pixels using slice with single color / multiple colors #97

Open
JonLevin25 opened this issue Dec 3, 2020 · 0 comments
Open

Set pixels using slice with single color / multiple colors #97

JonLevin25 opened this issue Dec 3, 2020 · 0 comments

Comments

@JonLevin25
Copy link

JonLevin25 commented Dec 3, 2020

Playing around with NeoPixel I thought of building some stuff on top using the slice syntax
i.e pixels[:len(pixels)//2] = (255, 0 ,0)
Which currently fails as the colors tuple must be at least the length of the slice

Using pixels.fill((255,0,0) could work, but only if you start at the beginning, not for arbitrary slices (i.e setting middle third with third = len(pixels)//3 then pixels[third: 2 * third] = (255, 0, 0)

Bonus: if a tuple is given, but not of the same length, It could be cool if it just repeated, meaning:
pixels[:7] = (R, G, B) would set the pixels (R, G, B, R, G, B, R)

Since this would have thrown an error before, it should be backwards-compatible.

I realize all this can be done manually but since slices are already supported it seems like a nice intuitive feature :)

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

1 participant