Skip to content

Add first and count params to fill #13

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions adafruit_pixelbuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,26 @@ def show(self):
"""
return self._transmit(self._post_brightness_buffer)

def fill(self, color: ColorUnion):
def fill(self, color: ColorUnion, first: int, count: int):
"""
Fills the given pixelbuf with the given color.
Fill all or part of the pixelbuf with the given color.

:param pixelbuf: A pixel object.
:param color: Color to set.
:param first: Index of first pixel to fill, starting from 0. Must-be in-bounds
:param count: Number of pixels to fill, as a positive value. 0 or unspecified will fill all
"""
r, g, b, w = self._parse_color(color)
for i in range(self._pixels):
end = 0
if first >= self._pixels:
pass
if count == 0:
end = self._pixels
else:
end = first + count
if end > self._pixels:
end = self._pixels
for i in range(first, end):
self._set_item(i, r, g, b, w)
if self.auto_write:
self.show()
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy