MCPcopy Create free account
hub / github.com/XingangPan/DragGAN / _get_array_priv

Function _get_array_priv

gui_utils/text_utils.py:45–69  ·  view source on GitHub ↗
(
    string: str, *,
    size: int = 32,
    max_width: Optional[int]=None,
    max_height: Optional[int]=None,
    min_size=10,
    shrink_coef=0.8,
    dropshadow_radius: int=None,
    offset_x: int=None,
    offset_y: int=None,
    **kwargs
)

Source from the content-addressed store, hash-verified

43
44@functools.lru_cache(maxsize=10000)
45def _get_array_priv(
46 string: str, *,
47 size: int = 32,
48 max_width: Optional[int]=None,
49 max_height: Optional[int]=None,
50 min_size=10,
51 shrink_coef=0.8,
52 dropshadow_radius: int=None,
53 offset_x: int=None,
54 offset_y: int=None,
55 **kwargs
56):
57 cur_size = size
58 array = None
59 while True:
60 if dropshadow_radius is not None:
61 # separate implementation for dropshadow text rendering
62 array = _get_array_impl_dropshadow(string, size=cur_size, radius=dropshadow_radius, offset_x=offset_x, offset_y=offset_y, **kwargs)
63 else:
64 array = _get_array_impl(string, size=cur_size, **kwargs)
65 height, width, _ = array.shape
66 if (max_width is None or width <= max_width) and (max_height is None or height <= max_height) or (cur_size <= min_size):
67 break
68 cur_size = max(int(cur_size * shrink_coef), min_size)
69 return array
70
71#----------------------------------------------------------------------------
72

Callers 1

get_arrayFunction · 0.85

Calls 2

_get_array_implFunction · 0.85

Tested by

no test coverage detected