forked from ladyada/Adafruit_CircuitPython_Display_Shapes
-
Notifications
You must be signed in to change notification settings - Fork 18
Changes to shape objects to explicitly set opaque property when changing colors #8
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,21 +20,11 @@ | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
""" | ||
`roundrect` | ||
`my_roundrect` | ||
================================================================================ | ||
|
||
Various common shapes for use with displayio - Rounded Rectangle shape! | ||
|
||
|
||
* Author(s): Limor Fried | ||
|
||
Implementation Notes | ||
-------------------- | ||
|
||
**Software and Dependencies:** | ||
|
||
* Adafruit CircuitPython firmware for the supported boards: | ||
https://github.com/adafruit/circuitpython/releases | ||
A slightly modified version of Adafruit_CircuitPython_Display_Shapes that includes | ||
an explicit call to palette.make_opaque() in the fill color setter function. | ||
|
||
""" | ||
|
||
|
@@ -65,16 +55,18 @@ def __init__(self, x, y, width, height, r, *, fill=None, outline=None, stroke=1) | |
self._palette = displayio.Palette(3) | ||
self._palette.make_transparent(0) | ||
self._bitmap = displayio.Bitmap(width, height, 3) | ||
for i in range(0, width): # draw the center chunk | ||
for j in range(r, height - r): # draw the center chunk | ||
self._bitmap[i, j] = 2 | ||
self._helper(r, r, r, color=2, fill=True, | ||
x_offset=width-2*r-1, y_offset=height-2*r-1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like it failed the checks because a space need to be added to this line. |
||
|
||
if fill is not None: | ||
for i in range(0, width): # draw the center chunk | ||
for j in range(r, height - r): # draw the center chunk | ||
self._bitmap[i, j] = 2 | ||
self._helper(r, r, r, color=2, fill=True, | ||
x_offset=width-2*r-1, y_offset=height-2*r-1) | ||
self._palette[2] = fill | ||
self._palette.make_opaque(2) | ||
else: | ||
self._palette.make_transparent(2) | ||
self._palette[2] = 0 | ||
|
||
if outline is not None: | ||
self._palette[1] = outline | ||
|
@@ -148,9 +140,11 @@ def fill(self): | |
@fill.setter | ||
def fill(self, color): | ||
if color is None: | ||
self._palette[2] = 0 | ||
self._palette.make_transparent(2) | ||
else: | ||
self._palette[2] = color | ||
self._palette.make_opaque(2) | ||
|
||
@property | ||
def outline(self): | ||
|
@@ -161,6 +155,8 @@ def outline(self): | |
@outline.setter | ||
def outline(self, color): | ||
if color is None: | ||
self._palette[1] = 0 | ||
self._palette.make_transparent(1) | ||
else: | ||
self._palette[1] = color | ||
self._palette.make_opaque(2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer true. It should document what a roundrect is.