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

Add RGBA support to Caret #805

Closed
pushfoo opened this issue Apr 8, 2023 · 1 comment · Fixed by #806
Closed

Add RGBA support to Caret #805

pushfoo opened this issue Apr 8, 2023 · 1 comment · Fixed by #806
Labels
enhancement New feature or request

Comments

@pushfoo
Copy link
Contributor

pushfoo commented Apr 8, 2023

tl;dr the rest of the codebase accepts RGBA, but Caret hasn't been updated yet

Other areas of the codebase (shapes, gui, the rest of text) have been updated to accept Tuple[int, int, int, int] for colors. However, Caret has not:

def __init__(self, layout, batch=None, color=(0, 0, 0)):
"""Create a caret for a layout.
By default the layout's batch is used, so the caret does not need to
be drawn explicitly.
:Parameters:
`layout` : `~pyglet.text.layout.TextLayout`
Layout to control.
`batch` : `~pyglet.graphics.Batch`
Graphics batch to add vertices to.
`color` : (int, int, int)
RGB tuple with components in range [0, 255].
"""
from pyglet import gl
self._layout = layout
batch = batch or layout.batch
group = layout.foreground_decoration_group
colors = (*color, 255, *color, 255)
self._list = group.program.vertex_list(2, gl.GL_LINES, batch, group, colors=('Bn', colors))

If there's no technical reason blocking it, can we add it?

@pushfoo pushfoo added the enhancement New feature or request label Apr 8, 2023
@benmoran56
Copy link
Member

Sure, that's valid. How about doing it the same way as Shapes, so we can support both RGB and RGBA, not breaking backwards compatibility?

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

Successfully merging a pull request may close this issue.

2 participants