MCPcopy Create free account
hub / github.com/Layout-Parser/layout-parser / _create_new_canvas

Function _create_new_canvas

src/layoutparser/visualization.py:103–124  ·  view source on GitHub ↗
(canvas, arrangement, text_background_color)

Source from the content-addressed store, hash-verified

101
102
103def _create_new_canvas(canvas, arrangement, text_background_color):
104
105 if arrangement == "lr":
106 new_canvas = Image.new(
107 "RGBA",
108 (canvas.width * 2, canvas.height),
109 color=text_background_color or DEFAULT_TEXT_BACKGROUND,
110 )
111 new_canvas.paste(canvas, (canvas.width, 0))
112
113 elif arrangement == "ud":
114 new_canvas = Image.new(
115 "RGBA",
116 (canvas.width, canvas.height * 2),
117 color=text_background_color or DEFAULT_TEXT_BACKGROUND,
118 )
119 new_canvas.paste(canvas, (0, canvas.height))
120
121 else:
122 raise ValueError(f"Invalid direction {arrangement}")
123
124 return new_canvas
125
126
127def _create_color_palette(types):

Callers 1

draw_textFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected