MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / parse_groupshape

Function parse_groupshape

utils/src/utils.py:223–255  ·  view source on GitHub ↗
(groupshape: GroupShape)

Source from the content-addressed store, hash-verified

221
222
223def parse_groupshape(groupshape: GroupShape):
224 assert isinstance(groupshape, GroupShape)
225 group_top_left_x = groupshape.left
226 group_top_left_y = groupshape.top
227 group_width = groupshape.width
228 group_height = groupshape.height
229 shape_top_left_x = min([sp.left for sp in groupshape.shapes])
230 shape_top_left_y = min([sp.top for sp in groupshape.shapes])
231 shape_width = (
232 max([sp.left + sp.width for sp in groupshape.shapes]) - shape_top_left_x
233 )
234 shape_height = (
235 max([sp.top + sp.height for sp in groupshape.shapes]) - shape_top_left_y
236 )
237 group_shape_xy = []
238 for sp in groupshape.shapes:
239 group_shape_left = (
240 sp.left - shape_top_left_x
241 ) * group_width / shape_width + group_top_left_x
242 group_shape_top = (
243 sp.top - shape_top_left_y
244 ) * group_height / shape_height + group_top_left_y
245 group_shape_width = sp.width * group_width / shape_width
246 group_shape_height = sp.height * group_height / shape_height
247 group_shape_xy.append(
248 {
249 "left": Length(group_shape_left),
250 "top": Length(group_shape_top),
251 "width": Length(group_shape_width),
252 "height": Length(group_shape_height),
253 }
254 )
255 return group_shape_xy
256
257
258def is_primitive(obj):

Callers 1

from_shapeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected