From 6b39198f15acab45054b73189e456a83674605ef Mon Sep 17 00:00:00 2001 From: LU Jialin Date: Thu, 7 Nov 2024 21:56:53 -0800 Subject: [PATCH 1/3] add opaque background color to actually show the black text --- arckit/vis.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arckit/vis.py b/arckit/vis.py index 1c3d622..c261480 100644 --- a/arckit/vis.py +++ b/arckit/vis.py @@ -16,6 +16,8 @@ '#FFFFFF' ] +bg_color = '#FFFFFF' # White + def draw_grid(grid, xmax=10, ymax=10, padding=.5, extra_bottom_padding=0.5, group=False, add_size=True, label='', bordercol='#111111ff'): """ Draws a grid, @@ -65,6 +67,12 @@ def draw_grid(grid, xmax=10, ymax=10, padding=.5, extra_bottom_padding=0.5, grou drawing = drawsvg.Group() else: drawing = drawsvg.Drawing(xsize+padding, ysize+padding+extra_bottom_padding, origin=(-0.5*padding, -0.5*padding)) + # Add background rectangle first + drawing.append(drawsvg.Rectangle( + -0.5*padding, -0.5*padding, # x, y position with extra padding + xsize+padding, ysize+padding+extra_bottom_padding, # width, height with padding + fill=bg_color # background color `bg_color` + )) drawing.set_pixel_scale(40) # drawing = drawsvg.Group() for j, row in enumerate(grid): From 526df1a5c3326fd7d84b0d45452d31f6133e84ef Mon Sep 17 00:00:00 2001 From: LU Jialin Date: Thu, 7 Nov 2024 21:57:19 -0800 Subject: [PATCH 2/3] misc, the task should be used as the input --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de175c7..7c7e4cd 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ When drawing tasks, arckit will intelligently resize all of the grids such that ```python >>> task = vis.draw_task(train_set[0], width=10, height=6, label='Example') ->>> vis.output_drawing(grid, "images/arcshow_example.png") # svg/pdf/png +>>> vis.output_drawing(task, "images/arcshow_example.png") # svg/pdf/png ``` ![Example of arckit output](./images/arcsave_example.png) From e53812994f608bd5ec9720e098bcf6a9b4e624b2 Mon Sep 17 00:00:00 2001 From: Mikel Bober-Irizar Date: Mon, 11 Nov 2024 13:34:28 +0000 Subject: [PATCH 3/3] Update grid background colour to #EEEFF6 --- arckit/vis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arckit/vis.py b/arckit/vis.py index c261480..c4435b8 100644 --- a/arckit/vis.py +++ b/arckit/vis.py @@ -16,7 +16,7 @@ '#FFFFFF' ] -bg_color = '#FFFFFF' # White +bg_color = '#EEEFF6' # White def draw_grid(grid, xmax=10, ymax=10, padding=.5, extra_bottom_padding=0.5, group=False, add_size=True, label='', bordercol='#111111ff'): """ @@ -270,4 +270,4 @@ def output_drawing(d: drawsvg.Drawing, filename: str, context=None): import cairosvg cairosvg.svg2pdf(bytestring=buffer.getvalue(), write_to=filename) else: - raise ValueError(f'Unknown file extension for {filename}') \ No newline at end of file + raise ValueError(f'Unknown file extension for {filename}')