drawlib 0.2.3.dev7__py3-none-any.whl → 0.2.4.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
drawlib/__init__.py CHANGED
@@ -14,7 +14,7 @@ import sys
14
14
  from typing import Final, List
15
15
 
16
16
  # please update here when you release new version
17
- LIB_VERSION: Final[str] = "0.2.3.dev7"
17
+ LIB_VERSION: Final[str] = "0.2.4.dev1"
18
18
 
19
19
  # please list active main committers (1+ commits per month)
20
20
  AUTHORS: Final[List[str]] = [
drawlib/v0_2/apis.py CHANGED
@@ -85,6 +85,7 @@ from drawlib.v0_2.private.core_canvas.canvas import (
85
85
  # canvas
86
86
  save,
87
87
  shape,
88
+ show,
88
89
  star,
89
90
  # text
90
91
  text,
@@ -166,11 +166,7 @@ class CanvasBase:
166
166
  validator.validate_canvas_args(locals())
167
167
 
168
168
  if len(self._artists) != 0:
169
- raise RuntimeError(
170
- "config() must be called before drawing. "
171
- "Please call clear() first if you want to "
172
- "initialize drawing configs and states."
173
- )
169
+ self._artists = []
174
170
 
175
171
  def config_size_dpi() -> None:
176
172
  if width is not None:
@@ -56,6 +56,25 @@ class Canvas(
56
56
  """
57
57
  super().__init__()
58
58
 
59
+ @error_handler
60
+ def show(self) -> None:
61
+ """Show canvas illustration."""
62
+ self._set_background()
63
+ zorder = self._draw_items()
64
+ self._remove_margin()
65
+
66
+ if not self._grid:
67
+ pyplot.show()
68
+ return
69
+
70
+ temp_artists = self._artists
71
+ self._artists = []
72
+ self._draw_grid(zorder)
73
+ pyplot.show()
74
+ self._remove_artists_from_ax() # remove grid
75
+ self._artists = temp_artists
76
+ self._remove_artists_from_ax() # remove drawing items
77
+
59
78
  @error_handler
60
79
  def save(
61
80
  self,
@@ -256,6 +275,7 @@ canvas = Canvas()
256
275
  clear = canvas.clear
257
276
  config = canvas.config
258
277
  save = canvas.save
278
+ show = canvas.show
259
279
  shape = canvas.shape
260
280
 
261
281
  # image
@@ -24,10 +24,9 @@ class BoxList:
24
24
  """A class to draw a list of boxes with text, supporting highlighting of certain boxes.
25
25
 
26
26
  Args:
27
- box_style (Union[str, ShapeStyle, None]): The style for the boxes.
28
- text_style (Union[str, ShapeTextStyle, None]): The style for the text inside the boxes.
29
- box_highlight_style (Union[str, ShapeStyle, None]): The style for the highlighted boxes.
30
- text_highlight_style (Union[str, ShapeTextStyle, None]): The style for the text inside the highlighted boxes.
27
+ default_box_style (Union[str, ShapeStyle, None]): The style for the boxes.
28
+ default_text_style (Union[str, ShapeTextStyle, None]): The style for the text inside the boxes.
29
+
31
30
  """
32
31
 
33
32
  @error_handler
@@ -41,9 +40,7 @@ class BoxList:
41
40
  Args:
42
41
  default_box_style (Union[str, ShapeStyle, None]): The style for the boxes.
43
42
  default_text_style (Union[str, ShapeTextStyle, None]): The style for the text inside the boxes.
44
- box_highlight_style (Union[str, ShapeStyle, None]): The style for the highlighted boxes.
45
- text_highlight_style (Union[str, ShapeTextStyle, None]):
46
- The style for the text inside the highlighted boxes.
43
+
47
44
  """
48
45
  if isinstance(default_box_style, str):
49
46
  default_box_style = dtheme.rectanglestyles.get(default_box_style)
@@ -79,6 +76,7 @@ class BoxList:
79
76
  text_style (Union[str, ShapeTextStyle, None], optional):
80
77
  The style for the text inside the box. Can be a style name, a ShapeTextStyle object, or None.
81
78
  If None, the default text style is used.
79
+
82
80
  """
83
81
  self.extend([text], box_style=box_style, text_style=text_style)
84
82
 
@@ -102,6 +100,7 @@ class BoxList:
102
100
  text_style (Union[str, ShapeTextStyle, None], optional):
103
101
  The style for the text inside the box. Can be a style name, a ShapeTextStyle object, or None.
104
102
  If None, the default text style is used.
103
+
105
104
  """
106
105
  is_custom_style = box_style is not None or text_style is not None
107
106
 
@@ -141,6 +140,7 @@ class BoxList:
141
140
  text_style (Union[str, ShapeTextStyle, None], optional):
142
141
  The style for the text inside the boxes. Can be a style name, a ShapeTextStyle object, or None.
143
142
  If None, the default text style is used.
143
+
144
144
  """
145
145
  is_custom_style = box_style is not None or text_style is not None
146
146
 
@@ -177,10 +177,6 @@ class BoxList:
177
177
  xy (Tuple[float, float]): The starting point (x, y) to draw the list of boxes.
178
178
  box_width (float): The width of each box.
179
179
  box_height (float): The height of each box.
180
- items (List[Any]): The list of items to be displayed inside the boxes.
181
- highlight_indexs (Optional[List[int]]):
182
- The list of indices of the boxes to be highlighted.
183
- length (Optional[int]): The total number of boxes to be drawn.
184
180
  align (Literal["left", "right", "bottom", "top"]):
185
181
  The alignment of the boxes relative to the starting point.
186
182
 
@@ -20,7 +20,19 @@ from drawlib.v0_2.private.util import error_handler
20
20
 
21
21
 
22
22
  class GridLayout:
23
- """Class for rendering multiple rectangles which fit to grid."""
23
+ """Class for rendering multiple rectangles which fit to grid.
24
+
25
+ Args:
26
+ num_column (int): The number of columns in the grid.
27
+ num_row (int): The number of rows in the grid.
28
+ default_r (int, optional): The default radius for the rectangles. Defaults to 0.
29
+ default_style (Union[str, ShapeStyle, None], optional): The default style for the rectangles.
30
+ Can be a string key, a ShapeStyle object, or None. Defaults to None.
31
+ default_textstyle (Union[str, ShapeTextStyle, None], optional): The default text style for the rectangles.
32
+ Can be a string key, a ShapeTextStyle object, or None. Defaults to None.
33
+ default_textangle (Optional[float], optional): The default angle for the text inside the rectangles.
34
+ If None, no angle is applied. Defaults to None.
35
+ """
24
36
 
25
37
  @error_handler
26
38
  def __init__(
@@ -32,7 +44,20 @@ class GridLayout:
32
44
  default_textstyle: Union[str, ShapeTextStyle, None] = None,
33
45
  default_textangle: Optional[float] = None,
34
46
  ) -> None:
35
- """Initialize class."""
47
+ """Initializes a GridLayout instance.
48
+
49
+ Args:
50
+ num_column (int): The number of columns in the grid.
51
+ num_row (int): The number of rows in the grid.
52
+ default_r (int, optional): The default radius for the rectangles. Defaults to 0.
53
+ default_style (Union[str, ShapeStyle, None], optional): The default style for the rectangles.
54
+ Can be a string key, a ShapeStyle object, or None. Defaults to None.
55
+ default_textstyle (Union[str, ShapeTextStyle, None], optional): The default text style for the rectangles.
56
+ Can be a string key, a ShapeTextStyle object, or None. Defaults to None.
57
+ default_textangle (Optional[float], optional): The default angle for the text inside the rectangles.
58
+ If None, no angle is applied. Defaults to None.
59
+
60
+ """
36
61
  self._num_column = num_column
37
62
  self._num_row = num_row
38
63
  self._default_r = default_r
@@ -27,7 +27,12 @@ class _PyramidItem:
27
27
 
28
28
 
29
29
  class Pyramid:
30
- """Class for rendering smart art pyramid."""
30
+ """Class for rendering smart art pyramids.
31
+
32
+ This class provides methods to create and manipulate pyramid-shaped smart art
33
+ diagrams. It supports custom styles, text styles, text angles, and text position
34
+ adjustments.
35
+ """
31
36
 
32
37
  @error_handler
33
38
  def __init__(
@@ -37,7 +42,21 @@ class Pyramid:
37
42
  default_textangle: Optional[float] = None,
38
43
  default_text_xy_shift: Optional[Tuple[float, float]] = None,
39
44
  ) -> None:
40
- """Initialize class."""
45
+ """Initializes a Pyramid instance with optional default styles and settings.
46
+
47
+ Args:
48
+ default_style (Union[str, ShapeStyle, None], optional): The default
49
+ style for the pyramid shapes. It can be a string that maps to a
50
+ `ShapeStyle` or a `ShapeStyle` instance. Defaults to None.
51
+ default_textstyle (Union[str, ShapeTextStyle, None], optional): The
52
+ default text style for the pyramid shapes. It can be a string that
53
+ maps to a `ShapeTextStyle` or a `ShapeTextStyle` instance. Defaults to None.
54
+ default_textangle (Optional[float], optional): The default rotation
55
+ angle for the text within the pyramid shapes. Defaults to None.
56
+ default_text_xy_shift (Optional[Tuple[float, float]], optional): The
57
+ default x and y shift for the text within the pyramid shapes.
58
+ Defaults to None.
59
+ """
41
60
  if isinstance(default_style, str):
42
61
  default_style = dtheme.rectanglestyles.get(default_style)
43
62
  self._default_style = default_style
@@ -52,8 +71,8 @@ class Pyramid:
52
71
  @error_handler
53
72
  def add( # noqa: C901
54
73
  self,
74
+ text: str,
55
75
  style: Union[str, ShapeStyle, None] = None,
56
- text: str = "",
57
76
  textstyle: Union[str, ShapeTextStyle, None] = None,
58
77
  textangle: Optional[float] = None,
59
78
  text_xy_shift: Optional[Tuple[float, float]] = None,
@@ -62,11 +81,11 @@ class Pyramid:
62
81
  Add an item to the pyramid.
63
82
 
64
83
  Args:
84
+ text (str): The text associated with the item.
65
85
  style (Union[str, ShapeStyle, None], optional):
66
86
  The style of the item.
67
87
  Can be a string key for a predefined style, a ShapeStyle object,
68
88
  or None to use the default style.
69
- text (str, optional): The text associated with the item. Default is an empty string.
70
89
  textstyle (Union[str, ShapeTextStyle, None], optional):
71
90
  The text style of the item. Can be a string key for a predefined text style,
72
91
  a ShapeTextStyle object, or None to use the default text style.
@@ -22,7 +22,12 @@ from drawlib.v0_2.private.util import error_handler
22
22
 
23
23
 
24
24
  class TreeNode:
25
- """Class for rendering smart art Tree."""
25
+ """Class for rendering smart art trees.
26
+
27
+ This class provides methods to create and manipulate tree-like smart art
28
+ diagrams, supporting custom text styles, line styles, and margins for
29
+ horizontal and vertical lines.
30
+ """
26
31
 
27
32
  _drawing_item_map: Dict[str, _TreeNodeDrawingItem] = {}
28
33
 
@@ -42,7 +47,32 @@ class TreeNode:
42
47
  default_line_horizontal_length: Optional[float] = None,
43
48
  default_line_vertical_margin: Optional[float] = None,
44
49
  ) -> None:
45
- """Initialize class."""
50
+ """Initializes a TreeNode instance with specific text, styles, and optional children.
51
+
52
+ Styles are mandatory for root node. Optional for child nodes.
53
+
54
+ Args:
55
+ text (str): The text content for the tree node.
56
+ textstyle (Union[str, TextStyle, None], optional): The text style for the node.
57
+ It can be a string that maps to a `TextStyle` or a `TextStyle` instance. Defaults to None.
58
+ linestyle (Union[str, LineStyle, None], optional): The line style for the node.
59
+ It can be a string that maps to a `LineStyle` or a `LineStyle` instance. Defaults to None.
60
+ line_horizontal_margin (Optional[float], optional): The margin for horizontal lines. Defaults to None.
61
+ line_horizontal_length (Optional[float], optional): The length of horizontal lines. Defaults to None.
62
+ line_vertical_margin (Optional[float], optional): The margin for vertical lines. Defaults to None.
63
+ children (Optional[List[TreeNode]], optional):
64
+ A list of child nodes connected to this node. Defaults to None.
65
+ default_textstyle (Union[str, TextStyle, None], optional):
66
+ The default text style for child nodes. Defaults to None.
67
+ default_linestyle (Union[str, LineStyle, None], optional):
68
+ The default line style for child nodes. Defaults to None.
69
+ default_line_horizontal_margin (Optional[float], optional):
70
+ The default horizontal margin for lines of child nodes. Defaults to None.
71
+ default_line_horizontal_length (Optional[float], optional):
72
+ The default horizontal length for lines of child nodes. Defaults to None.
73
+ default_line_vertical_margin (Optional[float], optional):
74
+ The default vertical margin for lines of child nodes. Defaults to None.
75
+ """
46
76
  self._text = text
47
77
 
48
78
  if isinstance(textstyle, str):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: drawlib
3
- Version: 0.2.3.dev7
3
+ Version: 0.2.4.dev1
4
4
  Summary: Python drawing library. Illustration as Code.
5
5
  Home-page: https://www.drawlib.com
6
6
  Author: Yuichi Ito
@@ -1,4 +1,4 @@
1
- drawlib/__init__.py,sha256=pyjdLbbUAFUzhoVCy3PoW8t4cN_seywKer9Rf10ioYI,2690
1
+ drawlib/__init__.py,sha256=FYGafjdFhAip0ghgep5Hm3YQQhWzyoWGxr02hHF_PJU,2690
2
2
  drawlib/__main__.py,sha256=UDsH6DiEIWBEwlClbYI10aWYBw_gOmaNCB0TSImWZ-c,604
3
3
  drawlib/apis.py,sha256=Q1Uz4U6IK63ZtjaV_UTWPZq7xDpxTz99qHfpGsL8SnI,531
4
4
  drawlib/assets/__init__.py,sha256=bYT4EWquLr0oyEziAuixlD9M4EPnMY6PyhknOxJjxqY,437
@@ -8,7 +8,7 @@ drawlib/assets/v0_2/fonts/__init__.py,sha256=PeL8idl5hfNNoqygvpDJyqj28ZCek7qxh5G
8
8
  drawlib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  drawlib/v0_2/__init__.py,sha256=dy_hxP-s7e-ZGXQKRYgjT02nwGKB5G0Qc6yrJD9M8Zg,729
10
10
  drawlib/v0_2/__main__.py,sha256=NHcSZyv4gK-Nh8NQTujSx396OK05IBjeVmaDKWKHJLU,549
11
- drawlib/v0_2/apis.py,sha256=hOKuBUwR2i5DBOcEeUQ4AxiIXHIdotj27Cr5p-KIf0M,2152
11
+ drawlib/v0_2/apis.py,sha256=f4pFTxKo19-R4ZWkNo9GU7a7oJdl4qdoLwqb7MNC-y0,2162
12
12
  drawlib/v0_2/private/__init__.py,sha256=vPaj6RbUQj1xOBPRxcKkoOq3kSiOmOlNnY5JnjV_OiY,455
13
13
  drawlib/v0_2/private/command.py,sha256=m6yeuLJfUPbn4KVmchsRsCrtFRTbuCI_OUsYd0NoLEg,19471
14
14
  drawlib/v0_2/private/core/__init__.py,sha256=qzZ4oWmEnMaEAKuQU2x9NvuZLg06fJEOOpR1S31OTS8,454
@@ -22,8 +22,8 @@ drawlib/v0_2/private/core/theme_officials.py,sha256=AeZdENE-B8kSTcDAnWLKU-b77Pss
22
22
  drawlib/v0_2/private/core/theme_style_caches.py,sha256=k22Jrm0nsZITg_Mv0qGyv5pMkivLOb-s-svnWqqm8xY,186385
23
23
  drawlib/v0_2/private/core/util.py,sha256=uf_VgDJ7HKwK1RuF-kIklwVVJnHXIR_SDoWeFy9jHiQ,30314
24
24
  drawlib/v0_2/private/core_canvas/__init__.py,sha256=6HANaWCLm6GjIU7cZGAOdUCrvIxbtQx3KTkQWK-nEhU,455
25
- drawlib/v0_2/private/core_canvas/base.py,sha256=FipdPyX9M-JWL9FQpAT1r8hoo9o1wyCS1QGx3kINwLQ,20603
26
- drawlib/v0_2/private/core_canvas/canvas.py,sha256=haDITKf-Wz2zA2zDC_NmrdH-QsSagukQ7LT7xEB2crY,9594
25
+ drawlib/v0_2/private/core_canvas/base.py,sha256=IJvE4zeFQ3pcRnWcI5vbKkO6VR7trw5z3ur9lhCTt68,20412
26
+ drawlib/v0_2/private/core_canvas/canvas.py,sha256=2Z-vJ-2Z465Z8Wpc5vSGdyLHU8CRd2D6LfBP26aDnNA,10144
27
27
  drawlib/v0_2/private/core_canvas/image.py,sha256=1KoLmCTbr4VoTZi0rI_e1_HIYOmpGklygeq5ACgwVus,6958
28
28
  drawlib/v0_2/private/core_canvas/line.py,sha256=7TN4pRDWzaanGYQaox7HywIPQuUx4CfOnwvM7mN2e7I,17954
29
29
  drawlib/v0_2/private/core_canvas/original_arrow.py,sha256=13MqxSEcWR9tbYmcrSdF8AMdjm8rkP6-q42Olk3jfKc,24466
@@ -41,16 +41,16 @@ drawlib/v0_2/private/icons/phosphor.py,sha256=4xwcmDvFB6raCZZFQdrU2eR7l5QhYz9Bg_
41
41
  drawlib/v0_2/private/icons/util.py,sha256=9ZH67tRO1diuzwhENVki6exgNFJbKa1WDICYsxDbaWs,2367
42
42
  drawlib/v0_2/private/logging.py,sha256=tZT62wFfPbwY2JBQVtwoS2qf7HBvCjfB-oXdATEnupc,802
43
43
  drawlib/v0_2/private/smartarts/__init__.py,sha256=ii_xf3fXWPvP4SqSdcLO0gIbx643oRbVch58KlaYAnA,445
44
- drawlib/v0_2/private/smartarts/boxlist.py,sha256=fPBauEoZAMO-7o_z6eZ32oJ-h0Gp0dL5dZPfW0jy14g,9679
44
+ drawlib/v0_2/private/smartarts/boxlist.py,sha256=_vaD5Qd6pKl-tK4hoy6FQDbn_Nhi2Vt_j3LjLGsa-Dc,8960
45
45
  drawlib/v0_2/private/smartarts/boxtree.py,sha256=f6EXkPMEkU8v4vvBxA2Bu2_vV6nJ1nIxppuj9UPhf2E,4655
46
46
  drawlib/v0_2/private/smartarts/bubblespeech.py,sha256=2ynQt0W5A0EGRpE1MX-1DQnd01NzM4zIjEUGunEWnIE,4219
47
47
  drawlib/v0_2/private/smartarts/bulletpoints.py,sha256=2wOa5O7pq1qlrdagPaiA9t3UrSCKYAZ5HuVGgrG04u4,6039
48
48
  drawlib/v0_2/private/smartarts/dsart.py,sha256=3wKpD4x_ZqZFG3QJAtD3NhKL7_lDlwJ3tY08sfUF02o,1245
49
- drawlib/v0_2/private/smartarts/gridlayout.py,sha256=BNaF44K1NJRELCWB0v4QuoCbOVQ1kEnMsu7wBrqdjn0,11870
50
- drawlib/v0_2/private/smartarts/pyramid.py,sha256=k2zIFQkrLGzLuhS5X0LwiV48wEsny75mVUQmhdWuFAo,14926
49
+ drawlib/v0_2/private/smartarts/gridlayout.py,sha256=U65oW5t6rljJW2fkyArsPooTRGd114X2wmWJbwJ8jZ4,13442
50
+ drawlib/v0_2/private/smartarts/pyramid.py,sha256=zSsCMGCIOvTZEbqbaN0lrBNRvG1WUHsCZn62zIaLwzM,15998
51
51
  drawlib/v0_2/private/smartarts/sourcecode.py,sha256=VkPrmxNeYR_E0kyfFsezAKJE7dVNIdrIJUsq348iqyE,8922
52
52
  drawlib/v0_2/private/smartarts/table.py,sha256=Fyji-xUt8JnZQPzbjt0GgibVB0qcr4zA2VgqDXddPmw,25407
53
- drawlib/v0_2/private/smartarts/tree.py,sha256=BStMQ77yO26RufYwfAbc5H4PEhCynkv9QKD5DbDasUg,11230
53
+ drawlib/v0_2/private/smartarts/tree.py,sha256=kp7BPAfrDB8ESTx9tS8RyaIaa4cNA65hQ87sP74ofLA,13292
54
54
  drawlib/v0_2/private/umls/activity.py,sha256=popFczuMoBcpUeB-KpLLY0wpTfwTknKoEM_e6JlAfUY,454
55
55
  drawlib/v0_2/private/umls/class_.py,sha256=Q8l8pWrxSTSulkUkClJNKjdR-RIgbAJ6AaAExQ5bEWk,451
56
56
  drawlib/v0_2/private/umls/communication.py,sha256=CRZBFlsBFM59THq0gG3bANxtCU_Vy8eC9OCKwD4W5Ng,459
@@ -75,8 +75,8 @@ drawlib/v0_2/private/validators/smartarts.py,sha256=fOAlC0syvZVk-GCLQgaPhhfWr3gc
75
75
  drawlib/v0_2/private/validators/style.py,sha256=R7aLlaVfzdo33L7GLQ3WVfzzD_EsgV2-Y7ERcbFq7QI,3308
76
76
  drawlib/v0_2/private/validators/text.py,sha256=ELT87nekr9hMx7m-wpVTku0QPxL3qCIX4cxI5RbFoIc,1126
77
77
  drawlib/v0_2/private/validators/types.py,sha256=KtiIgivuaFyFaxIGeqr5N8xpzqIk9soiacSzcFDdjSA,4155
78
- drawlib-0.2.3.dev7.dist-info/LICENSE.txt,sha256=h_ZiliCgEDqIYpxmUPmqGGP87VBcUHil1S4wUI48ZKg,11344
79
- drawlib-0.2.3.dev7.dist-info/METADATA,sha256=Jl62LmhaUAhBgsh5XF-GfIQXhGIJvZvMIO0luZn4nAM,4007
80
- drawlib-0.2.3.dev7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
81
- drawlib-0.2.3.dev7.dist-info/entry_points.txt,sha256=Lp6mbrRMP-g6c7P6Iz21CEjceLITCWrma3b0ncP30oQ,49
82
- drawlib-0.2.3.dev7.dist-info/RECORD,,
78
+ drawlib-0.2.4.dev1.dist-info/LICENSE.txt,sha256=h_ZiliCgEDqIYpxmUPmqGGP87VBcUHil1S4wUI48ZKg,11344
79
+ drawlib-0.2.4.dev1.dist-info/METADATA,sha256=0bCzDxjqdSuyhY5hsKgacUbsM3Jocj_jYEcKMxEQvIg,4007
80
+ drawlib-0.2.4.dev1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
81
+ drawlib-0.2.4.dev1.dist-info/entry_points.txt,sha256=Lp6mbrRMP-g6c7P6Iz21CEjceLITCWrma3b0ncP30oQ,49
82
+ drawlib-0.2.4.dev1.dist-info/RECORD,,