Skip to content

Commit

Permalink
editable bg color?
Browse files Browse the repository at this point in the history
  • Loading branch information
ejkaplan committed Jun 23, 2024
1 parent 57336a2 commit 7e5dd25
Show file tree
Hide file tree
Showing 2 changed files with 595 additions and 521 deletions.
5 changes: 4 additions & 1 deletion elkplot/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def render(
width: float | pint.Quantity,
height: float | pint.Quantity,
dpi: float = 64,
bg_color: tuple[float,...] = (0, 0, 0),
) -> None:
"""
NOTE: You will probably not want to call this directly and instead use elkplot.draw
Expand All @@ -71,14 +72,16 @@ def render(
:param dpi: How large would you like the preview shown in screen pixels per plotter-inch
:return:
"""
if len(bg_color) == 3:
bg_color += (255,)
if isinstance(width, pint.Quantity):
width = width.to("inch").magnitude
if isinstance(height, pint.Quantity):
height = height.to("inch").magnitude
batch = _batch_drawings(drawings, height, dpi)
config = gl.Config(sample_buffers=1, samples=8, double_buffer=True)
win = window.Window(
int(width * dpi), int(height * dpi), "plot preview", config=config
int(width * dpi), int(height * dpi), "plot preview", config=config, color=bg_color
)

@win.event
Expand Down
Loading

0 comments on commit 7e5dd25

Please sign in to comment.